4 ms·
const int world = 42; const int const * const hello = &world ; Apparently, you can be very const and `gcc -Wall -Wextra -std=c99` won't raise any complaint
by knome 6y ago
const int world = 42;
const int const * const hello = &world ;
Apparently, you can be very const and `gcc -Wall -Wextra -std=c99` won't raise any complaints.
- teddyh 6y agoFirstly, isn’t that a syntax error? There’s a stray “const” in there. You probably meant const int * const hello = &world; Secondly, what should the compiler complain about? You have a const int, and then a const pointer to const int, pointing to that first const int. What’s the problem? Thirdly, the latest C version supported by GCC is “-std=c17”.
- tick_tock_tick 6y agoNah const is fun int main() { const int world = 42; const const const int const const * const const hello = &world; return 0; } Is a valid program https://onlinegdb.com/SJcwJrRzd https://onlinegdb.com/SJcwJrRzd
- teddyh 6y agoSure, but those extra “const” do not mean anything, and are apparently ignored by the compiler.