public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43633]  New: sizeof returns wrong size for large long long values when using -std=c99
@ 2010-04-02 23:00 sje at cup dot hp dot com
  2010-04-02 23:04 ` [Bug c/43633] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sje at cup dot hp dot com @ 2010-04-02 23:00 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-05 12:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-02 23:00 [Bug c/43633] New: sizeof returns wrong size for large long long values when using -std=c99 sje at cup dot hp dot com
2010-04-02 23:04 ` [Bug c/43633] " pinskia at gcc dot gnu dot org
2010-04-03  9:16 ` schwab at linux-m68k dot org
2010-04-05 12:55 ` truedfx at gentoo dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).