warn/croak on "string" "string" auto-joins

Robert Dewar dewar@gnat.com
Tue Aug 17 23:02:00 GMT 2004


Adam Monsen wrote:

> String auto-joins can be dangerous. Is there a way to tell the
> compiler to warn/croak when an auto-join occurs?

Seems a bit odd to warn on a perfectly normal non-suspicious
usage.
> 
> For instance, find the bug in this code:
> 
> char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
> "Aug" "Sep", "Oct", "Nov", "Dec"};

To me there is no bug, though for sure I can guess that the programmer
did not mean to make the 8'th entry 6 characters long.
> 
> If not, I'd like to suggest a way to ask the compiler to strictly
> check for this.

I suppose a warning flag would be innocuous, provided it was not
included in -Wall.



More information about the Gcc mailing list