Meaning of the warning

H

Harald van Dijk

Harald said:
... snip ...

(However, even without -Wwrite-strings, gcc has a bug in which the
equally strictly conforming

int main(void) {
if (0) ""[0] = 'x';
}

is unconditionally rejected.)

Not a bug. "" is a constant string, stored in (possibly) constant
memory, and thus is not writable. You may be complaining that gcc
hasn't bother to notice that the statment won't be executed, and thus
should suppress the message. However, compilers are allowed to emit all
the messages they wish.

I am complaining not that GCC warns about this program (which would be
conforming), but that it issues an error message and refuses to compile
it at all, in all non-conforming, mostly-conforming, and conforming
modes. I posted quite clearly that the program was "unconditionally
rejected". If it got compiled, with or without warnings, it would have
been accepted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top