Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

/Qcheck-pointers:rw giving unhelpful output..

Daniel_Faken
Beginner
513 Views

Hello,

Compiling this simple test program:

#include <iostream>
#include <fstream>

int main(int argc, char *argv[])
{
std::ifstream s(argv[1], std::ios_base::in);

return 0;
}

with

icl /Qcheck-pointers:rw /Zi /Od iostreamTest.cpp -o tst

(on Win7, with Visual Studio 11 installed, ICL version: Version 13.1.3.198 Build 20130607)

yields this output when I run the program:

CHKP: Bounds check error
lb: 0X000000000022F7C8
ub: 0X000000000022F827
addr: 0X000000000022F7C4
end: 0X000000000022F7C7
size: 4
Traceback:
std::basic_istream<char, std::char_traits<char> >::basic_istream [0x3FB430A5]
in file C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\istream at line 31
std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream [0x3FB5B1E3]
in file C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\fstream at line 739
main [0x3FB64A21]
in file C:\memudev\trunk\SEMulator3D\iostreamTest.cpp at line 6
__tmainCRTStartup [0x3FB97404]
in file f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c at line 241
BaseThreadInitThunk [0x76E3652D]
RtlUserThreadStart [0x76F6C541]
CHKP: Bounds check error
lb: 0X000000000022F7C8
ub: 0X000000000022F827
addr: 0X000000000022F7C4
end: 0X000000000022F7C7
size: 4
Traceback:
std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream [0x3FB5B7A0]
in file C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\fstream at line 739
main [0x3FB64A21]
in file C:\memudev\trunk\SEMulator3D\iostreamTest.cpp at line 6
__tmainCRTStartup [0x3FB97404]
in file f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c at line 241
BaseThreadInitThunk [0x76E3652D]
RtlUserThreadStart [0x76F6C541]

Am I doing something wrong?

I would really like to use the "check pointers" functionality with our program, but it gives me a huge amount of output like the above (except ~300k lines) and I am unable to find anything useful due to the huge amount of (what seems like) noise.

thanks for any help,

Daniel

0 Kudos
3 Replies
Casey
Beginner
513 Views

The part relevant to you is this (bolded by me):

main [0x3FB64A21]
in file C:\memudev\trunk\SEMulator3D\iostreamTest.cpp at line 6,

which correctly identifies the line in your code where you make use of the pointer.  The traceback by necessity has to start deeper in the code because the derefernce that results in the invalid access happens inside of ifstream, not your code.

0 Kudos
Daniel_Faken
Beginner
513 Views

Casey,

  Yes, but why is there an invalid access?

  I neglected to say that argv[1] is valid -- I am passing command line parameters!

  If I put this before the declaration of std::ifstream:

std::cout << "argv[1] is: " << argv[1] << std::endl;

  then it prints the first parameter before the "CHKP: Bounds check error" I posted previously.

thanks, Daniel

0 Kudos
Casey
Beginner
513 Views

Sorry, I assumed an invalid point was passed.  I cannot replicate the behavior on linux icpc 14.0.1 with -check-pointers=rw.

0 Kudos
Reply