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;
}
}