[cfe-dev] Taking the address of an Objective-C @selector expression
Tom Honermann
thonermann at coverity.com
Mon Apr 27 11:21:28 PDT 2015
Objective-C @selector expressions yield an rvalue. However, Clang
(trunk, r234313) allows taking the address of such an expression:
$ cat t.m
void f() {
@selector(AMethod);
&@selector(AMethod);
}
$ clang --version
clang version 3.7.0 (trunk 234313)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang -w -c t.m; echo $?
0
Gcc (4.8.0) rejects:
$ gcc -c t.m
t.m: In function ‘main’:
t.m:5:20: error: lvalue required as unary ‘&’ operand
printf("%p\n", &@selector(AMethod));
^
I presume acceptance is a Clang bug. Any dissenters?
Tom.
More information about the cfe-dev
mailing list