My Oracle Support Banner

SS12U1 & SS12.3 Generate Wrong Code For +=, Op Int() And Pointer Math (Doc ID 1549961.1)

Last updated on MARCH 01, 2019

Applies to:

Oracle Solaris Studio - Version Sun Studio 12 Update 1 to 12.3 [Release 12]
Information in this document applies to any platform.
The test consists of several individual tests, each combining one data type for example char, long, double, etc with one pointer type such as char *, long *, etc .

In each, the user shows three constructs that correctly compute a value, and the one that fails, even though they all should be equivalent.

Of particular interest, for hints as to where the bug may be hiding, is the comparison between ptr3 += offset (wrong) and the one with explicit cast such as ptr2 += (short)offset, which comes out correct.

Here is an example output.

Typical entries from program:

#=# ptr: long* / int: char
FakeInt offset(123);
ptr0 = ptr0 + 123 --> 1ec
ptr1 = ptr1 + offset --> 1ec: good
ptr2 += (char)offset --> 1ec: good
ptr3 += offset --> ffbfffd5: bad

#=# ptr: double* / int: long long
FakeInt offset(123);
ptr0 = ptr0 + 123 --> 3d8
ptr1 = ptr1 + offset --> 3d8: good
ptr2 += (long long)offset --> 3d8: good
ptr3 += offset --> ffbfffd5: bad

The value of ptr3 should be the same with the other three, but it is not.

Bad code is generated here, and programer have no way of knowing how to trace back the origins of these when they hit this bad code generation.


C++ 5.10 (Sun Studio 12.1) to C++ 5.12 (Oracle Solaris Studio 12.3) generate wrong code for +=, op int() and pointer math.


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.