Today I tried clang on a project I have developed some time ago. I was suprised when it encountered a compilation error, since I had compiled my project successfully using g++.
This short snippet reproduces the line where the error was encountered:
int main() {
__attribute__((aligned(16)) char arr[5];
}
Which produces this error:
test.cpp:2:32: error: expected ')'
__attribute__((aligned(16)) char arr[5];
^
)
As you can see, there is an umbalanced parenthesis. There are three '(', and two ')'. This clearly looks like it should actually produce a compilation error.
Is this a valid usage of this keyword? I can't seem to find anything on the documentation that indicates it is.
I'm using g++ 4.5.2 and clang 2.8.
Note that this error is detected when using gcc instead of g++.
This would be a compiler bug. The compiler sees __attribute__
followed by two opening parentheses, some other tokens and then two closing parentheses, which is probably the “definition” of what an __attribute__
should look like, e.g.
<attribute> ::=
__attribute__
'(('
something'))'
My guess is that the tokens in between are being interpreted as aligned(16
and by some miracle it still works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With