[cfe-dev] clang vs. gcc
Neil Booth
neil at daikokuya.co.uk
Wed Apr 29 15:14:09 PDT 2009
Filipe Cabecinhas wrote:-
> Hi,
>
> clang doesn't compile the following code:
> ---------------------------
> [filcab at farnsworth ~] $ cat a.c
> #include <stdio.h>
>
> extern void a;
>
> int main ()
> {
> printf("%p\n", &a);
> return 0;
> }
> ---------------------------
>
> [filcab at farnsworth ~] $ gcc -c a.c
> [filcab at farnsworth ~] $ clang -c a.c
> a.c:7:18: error: address expression must be an lvalue or a function
> designator
> printf("%p\n", &a);
> ^~
> 1 diagnostic generated.
>
> Should I file a bug report or is it intended? If you want to know, it's
> from valgrind's source code. The symbol acts as a marker and is defined
> in a .S file.
If you declare it instead as
extern const void a;
the code is valid C.
Neil.
More information about the cfe-dev
mailing list