APAR status
Closed as user error.
Error description
PROBLEM DESCRIPTION: -------------------- Problems with the streaming reading the hex string (with 0x as p converting to an interger. - The character "0x0A" from stream buffer should be converted to if the hex flag not set thus printing a corresponding decimal value of 10. - The result from the test case printed 0 instead. - I suspect that the compiler is not recognizing the prefix "0x" is only converting the characters before "x" (since x is not a v decimal digit). - This is not working as the documentation states it should. - Summarizing from the compiler online documentation: If the hex flag is not set, the character conversion is done acc to the C++ lexical convention. i.e. If these characters begins w either "0x" or "0X", the subsequent characters are converted to hexadecimal value. ENVIRONMENT: ------------ AIX433 vacpp v5.03 TESTCASE: --------- // test2.C // // INCLUDES // #include <iostream.h> #include <strstream.h> int main() { int childVal; char* value("01x0A"); cout << "value: " << value << endl; // We have a hex value istrstream valBuf(value); valBuf >> childVal; cout << "ChildVal: " << chi } COMPILE COMMAND: ---------------- xlC test2.C EXPECTED RESULTS: ----------------- value: 0x0A ChildVal: 10 ACTUAL RESULTS: --------------- value: 0x0A ChildVal: 0
Local fix
- Remove the "0x" prefix and use the hex manipulator. e.g. char* value("0A"); valBuf >> hex >> childVal Please see test case.
Problem summary
Problem conclusion
Temporary fix
Comments
The behavior described in the APAR occurs only when no format flag is set. This condition can be produced by clearing the ios::basefield as in the following exampl #include <iostream.h> #include <strstream.h> int main() { int childVal; char* value("0x0A"); cout << "value: " << value << endl; // We have a hex value istrstream valBuf(value); // This cleares format flags valBuf.setf(0, ios::basefield); valBuf >> childVal; cout << "ChildVal: " << childVal << endl; }
APAR Information
APAR number
IY32387
Reported component name
VA C++ PROF FOR
Reported component ID
5765E2600
Reported release
500
Status
CLOSED USE
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2002-06-21
Closed date
2007-11-06
Last modified date
2007-11-06
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
VA C++ PROF FOR
Fixed component ID
5765E2600
Applicable component levels
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
Rate this page
Please take a moment to complete this form to help us better serve you.
