public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mbuilov at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/46045] incorrect code generated if redecalring local variable in do-while(0) Date: Sun, 17 Oct 2010 16:19:00 -0000 [thread overview] Message-ID: <20101017161900.Qoth4PQgcaEVFvwaQfHVqZzQeg_FKPaoZVildw0oEiU@z> (raw) In-Reply-To: <bug-46045-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46045 --- Comment #4 from Michael Builov <mbuilov at gmail dot com> 2010-10-17 16:19:37 UTC --- Just a warning with -Wextra, but no warnings with -Wall -pedantic. I found a bug with this code: struct A { int k; int m; }; #define dump(_a_) \ do { \ struct A *a = _a_; \ printk("%d, %d\n", a->k, a->m); \ } while (0) void foo(struct A *b, struct A *a) { dump(b); /* fine */ dump(a); /* crash */ } This code compiles and runs fine with Sun cc, but crashes with gcc. I think it is definitely a bug in gcc, this code compiled only with extra warnings (not enabled by default in linux kernel) should not crash. The best way to fix this issue - generate an error message, like when redeclaring variable in function: void bar(struct A *a) { struct A *a = a; /* error: 'a' redeclared as different kind of symbol */ } strange, but no errors/non-extra warnings with: void bar(struct A *a) { { struct A *a = a; } }
prev parent reply other threads:[~2010-10-17 16:19 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-10-16 13:26 [Bug c/46045] New: " mbuilov at gmail dot com 2010-10-16 13:32 ` [Bug c/46045] " zsojka at seznam dot cz 2010-10-16 18:44 ` rguenth at gcc dot gnu.org 2010-10-17 15:51 ` mbuilov at gmail dot com 2010-10-17 16:19 ` mbuilov at gmail dot com [this message]
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=20101017161900.Qoth4PQgcaEVFvwaQfHVqZzQeg_FKPaoZVildw0oEiU@z \ --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).