16 ms·
Something I found yesterday: static char * s = * &"hello"; This should not compile, clang refuses it, and it is not part of the C standard. GCC accepts it, bu
by andrewchambers 12y ago
Something I found yesterday:
static char * s = * &"hello";
This should not compile, clang refuses it, and it is not part of the C standard. GCC accepts it, but is it worth even submitting a bug report?
- plorkyeran 12y agoClang 3.5 compiles that for me without warnings even with -Weverything. String literals in C (but not C++) aren't const for legacy reasons despite not being modifiable.
- andrewchambers 12y agoSorry, I made a mistake. I think it is: static char s[] = * &"foo"; The c standard says char array initializers are either a string, or a string surrounded by optional '{}' .
- plorkyeran 12y ago-pedantic gives "warning: array initialized from parenthesized string constant" for that, so I'm guessing it's an unintended consequence of a nonstandard extension. Might be worth reporting since at the minimum the warning is wrong.