A fix is available
APAR status
Closed as program error.
Error description
The C++ compiler generates a warning message: 1540-2908 (W) The subscript -1 is less than zero. The subscript of an array should be greater than or equal to zero. when compiling code that use the return value of a funtion that returns a pointer to char with the array subscript notation to do pointer arithmetic, when the value of the array subscript is less than zero. For example, compiling the following testcase: const char* ptr (); int foobar () { return ptr ()[-1]; } results in the warning message: "testcase.C", line 5.17: 1540-2908 (W) The subscript -1 is less than zero. The subscript of an array should be greater than or equal to zero.
Local fix
The warning message can be suppressed using the -qsuppress compiler option, specifically -qsuppress=1540-2908
Problem summary
Same as submitter's text.
Problem conclusion
The compiler looks for array indexing and checks for any obvious out of bounds indexing. Part of the check is to find the name of the array being indexed. In some cases like in this defect, the address of the memory being indexed is not derived from a variable name. In these cases the compiler will think the array expression is derived off of an array and can continue the index check.
Temporary fix
Comments
APAR Information
APAR number
LI70536
Reported component name
XL C/C++ SLES9
Reported component ID
5724K7700
Reported release
700
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2004-12-08
Closed date
2004-12-15
Last modified date
2005-04-18
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Modules/Macros
DEFSRXXX
Fix information
Applicable component levels
R700 PSY
UP
[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Document Information
Modified date:
15 October 2021