public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "torger at ludd dot luth dot se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/18426] New: -Wstrict-aliasing fails to report simple case of breaking strict aliasing rules
Date: Thu, 11 Nov 2004 06:32:00 -0000	[thread overview]
Message-ID: <20041111063228.18426.torger@ludd.luth.se> (raw)

/* 
 
x86 platform. 
 
This simple program with the obvious breaking of strict aliasing  
rules does not generate a warning with -Wstrict-aliasing 
 
gcc -Wall -Wstrict-aliasing test.c 
 
tested on Pentium 4 
 
gcc 3.4.2, gcc 3.3.5 and gcc 3.2.3, as built for debian unstable 
2004 Nov 9 
 
*/ 
 
#include <stdio.h> 
 
unsigned long 
hash(void *key) 
{ 
    unsigned long long u[1]; 
    u[0] = *(unsigned long long *)key; 
    return ((unsigned long *)u)[0] ^ ((unsigned long *)u)[1]; 
} 
 
int 
main(void) 
{ 
    unsigned long long ull; 
 
    ull = 0xDEADBEAF; 
     
    fprintf(stderr, "%08lX\n", hash(&ull)); 
    return 0; 
}

-- 
           Summary: -Wstrict-aliasing fails to report simple case of
                    breaking strict aliasing rules
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: torger at ludd dot luth dot se
                CC: gcc-bugs at gcc dot gnu dot org


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


             reply	other threads:[~2004-11-11  6:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-11  6:32 torger at ludd dot luth dot se [this message]
2004-11-11  6:35 ` [Bug c/18426] " pinskia at gcc dot gnu dot org
2004-11-11 12:33 ` giovannibajo at libero dot it
2005-09-18  1:40 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041111063228.18426.torger@ludd.luth.se \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).