Analyzers
Support for Analyzers (Intel VTune™ Profiler, Intel Advisor, Intel Inspector)
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
4554 Discussions

Passing string longer than 32 chars - first 16 bytes get filled with 0

Rajko_T_
Beginner
90 Views

Consider this simple program:

#include <string>
#include <assert.h>

void foo(const std::string& str)
{
   assert(str[0] != 0);
}

int main()
{
   foo("Test longer than 32 characters like this");
   return 0;
}

If the string passed to foo() is longer than 32 characters, then the assert throws an error. Detailed inspection shows first 16 characters of 'str' to be filled with 0 (therefore the string is - unexpectedly - altered)! Any workarounds?

Ray

InspectorXE 2016 - Update 2
Visual Studio 2015 Community

0 Kudos
3 Replies
Kevin_O_Intel1
Employee
90 Views

 

Hi,

What type of  Inspector analysis are you running?

It sounds like you might be running into a memory checker guard zone.

Can you try running a level 2 "Detect memory problems" analysis?

I'll run your example and see if under which conditions the issue duplicates.

Regards,

Kevin

Rajko_T_
Beginner
90 Views

Hi,

It happens only when running with "Enable debugger when problem detected" option (level 2 or 3). At Level 1 or with "Analyze without debugger", no problems are encountered.

Ray

 

Kevin_O_Intel1
Employee
90 Views

 

I just tested your example using the 2017 beta version of Inspector.

I'm not seeing the issue with this version. Can you try the 2017 beta?

Kevin

Reply