[Bug c/43633] New: sizeof returns wrong size for large long long values when using -std=c99

sje at cup dot hp dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 2 23:00:00 GMT 2010


If I compile a program with -std=c99 and do a sizeof of a constant that is
larger then LONG_LONG_MAX but smaller then ULONG_LONG_MAX I get 16 instead of
8.  For values larger then ULONG_LONG_MAX I get 8.  I can reproduce this on x86
Linux and IA64 HP-UX (and probably other systems).    Here is a test case that
should show the problem on any systems where LONG LONG is 8 bytes.  Compiled
without -std=c99 all the prints will print '8', with '-std=c99' the middle two
prints will print out 16 instead of 8.  Reproducable with ToT and going back to
at least 4.1.0.

#include <stdio.h>
main()
{
        /* LONG_LONG_MAX */
        printf("%ld\n", sizeof(9223372036854775807LL));
        /* LONG_LONG_MAX + 1 */
        printf("%ld\n", sizeof(9223372036854775808LL));
        /* ULONG_LONG_MAX as a long long type */
        printf("%ld\n", sizeof(18446744073709551615LL));
        /* ULONG_LONG_MAX + 1 as a long long type */
        printf("%ld\n", sizeof(18446744073709551616LL));
}


-- 
           Summary: sizeof returns wrong size for large long long values
                    when using -std=c99
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sje at cup dot hp dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43633



More information about the Gcc-bugs mailing list