public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anvoebugz at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/39268] New: printf changes fstrict-aliasing behaviour Date: Sun, 22 Feb 2009 23:32:00 -0000 [thread overview] Message-ID: <bug-39268-17084@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2192 bytes --] It is strange that using printf that doesn't use any variables disables abort. $ cat test2.c #include <stdlib.h> #include <stdio.h> int main (void) { int a = 0x12345678; short *b = (short *) &a; b[1] = 0; printf("\n"); if (a == 0x12345678) abort(); exit(0); } $ gcc -fstrict-aliasing -O2 -Wall test2.c test2.c: In function main: test2.c:8: warning: likely type-punning may break strict-aliasing rules: object *{unknown} of main type short int is referenced at or around test2.c:8 and may be aliased to object a of main type int which is referenced at or around test2.c:6. $ ./a.out $ The conditional jump is activated when printf is using: @@ -7,9 +7,16 @@ .LFB20: subq $24, %rsp .LCFI0: + movl $10, %edi movl $305419896, 20(%rsp) movw $0, 22(%rsp) + call putchar + cmpl $305419896, 20(%rsp) + jne .L2 call abort +.L2: + xorl %edi, %edi + call exit .LFE20: .size main, .-main .section .eh_frame,"a",@progbits $ gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux Thread model: posix gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) -- Summary: printf changes fstrict-aliasing behaviour Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: anvoebugz at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39268
next reply other threads:[~2009-02-22 23:32 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-02-22 23:32 anvoebugz at gmail dot com [this message] 2009-02-22 23:39 ` [Bug tree-optimization/39268] " pinskia at gcc dot gnu dot org 2009-02-23 0:41 ` steven 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=bug-39268-17084@http.gcc.gnu.org/bugzilla/ \ --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: linkBe 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).