I've found some code like (many problems in the following code):
//setup consistent in each of the bad code examples
string someString;
char* nullValue = getenv("NONEXISTENT"); // some non-existent environment variable
// bad code example 1:
char x[1024];
sprintf(x," some text%s ", nullValue); //crashes on solaris, what about linux?
// bad code example 2:
someString += nullValue; // What happens here?
//bad code example 3:
someString.append(nullValue); // What happens here?
//bad code example 4:
string nextString=string(nullValue); //What happens here?
cout<<nextString;
We're using solaris, linux, gcc, sunstudio, and will quite possibly use clang++ in the future. Is the behaviour of this code consistent across platform and compiler? I couldn't find specs that describe expected behaviour in all the cases of the above code.
At present, we have problems running our code using gcc (and on linux), is the above code a likely cause?
If the code above acts the same in all of these environments, that's valuable information (even if the behavior is a crash) for me because I will know that this isn't the reason for our linux problems.
sprintfcall looks strange, shouldn't there be a%ssomewhere ?xisn't used in that code, so the sprintf is pointless & confusing. And describe your actual problem.nullValuebeing null before using it?