public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61579] New: -Wwrite-strings does not behave as a warning option
@ 2014-06-21 11:34 bugdal at aerifal dot cx
  2014-06-21 15:45 ` [Bug c/61579] " manu at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2014-06-21 11:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61579

            Bug ID: 61579
           Summary: -Wwrite-strings does not behave as a warning option
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx

Unlike other -W family options, -Wwrite-strings does not actually behave as a
warning option but as an option that alters the language semantics. I think
this inconsistency should be considered a bug and fixed. It leads to multiple
issues:

1. Warning messages wrongly show as [enabled by default] rather than
[-Wwrite-strings], since discarding const qualifier is enabled by default.

2. Some code which should produce a warning actually produces an error. As a
trivial but stupid example, if(0)*""=0; One can of course construct
non-trivial, non-stupid examples of this, particularly with the ?: operator.

3. The semantics of code using __typeof__, ?:, and now more importantly with
C11, _Generic, are changed by -Wwrite-strings. As a particularly bad case, I
think this could lead to the introduction of aliasing violations and undefined
behavior in code that had well-defined behavior without -Wwrite-strings.

Ideally the current implementation of -Wwrite-strings should be scrapped and
replaced with one that actually detects particular usage that's deemed
dangerous rather than changing the language semantics.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-22 17:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-21 11:34 [Bug c/61579] New: -Wwrite-strings does not behave as a warning option bugdal at aerifal dot cx
2014-06-21 15:45 ` [Bug c/61579] " manu at gcc dot gnu.org
2014-07-22 16:50 ` mpolacek at gcc dot gnu.org
2020-07-22 13:22 ` david at westcontrol dot com
2020-07-22 13:42 ` manu at gcc dot gnu.org
2020-07-22 17:32 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).