compiler thoughts

All | Personal | Sun
« enumerations | Main | relocatable GCCfss »
20070226 Monday February 26, 2007

interesting bug

While working on building OpenSolaris with gcc4/gccfss I encountered one interesting bug which can be demonstrated by the following simple C program:

void foo (long long *);

void bar (long a, long long b)
{
   typeof (a+b) c;
   foo (&c);
}

compiled with gcc 3.4 it will print the warning:

$ gcc3 -c simple.c -m64
simple.c: In function `bar':
simple.c:6: warning: passing arg 1 of `foo' from incompatible pointer type

whereas gcc 4.x will compile this testcase without any warnings.

The reason for that is GCC 3.x consider 'long + long_long' expression as 'long' type in 64-bit mode which is incorrect.

Why would I care ?

There are multiple places in OpenSolaris where it needs to print 64-bit value and it is done with '%llx' printf specifier. Due to this gcc 3.4 bug the Solaris sources were using '%lx' specifier to print expressions involving long and longlong types and now our changes to compile ON with gcc 4.x would break ON build with /usr/sfw/bin/gcc 3.4 unless the fix can be backported into "csl-sol210-3_4" Solaris specific gcc branch.

All in all, Solaris seems to be overdue to upgrade to some newer version of GCC.

Posted by alexey ( Feb 26 2007, 12:45:09 PM PST ) Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

Disclaimer:

This site is a personal blog and is to be used for informational purposes only. The views expressed on this blog are those of the author only, and should not be attributed to any past or present employers.

Calendar

RSS Feeds

Search

Links

Navigation

Referers