public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106416] New: -Wint-conversion should be an error, not a pedwarn
@ 2022-07-22 22:55 redi at gcc dot gnu.org
  2022-07-25 14:16 ` [Bug c/106416] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-22 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106416
           Summary: -Wint-conversion should be an error, not a pedwarn
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Aaron Ballman and I discussed this recently, and now he just made this an error
in Clang, with the following justification:

  Clang has traditionally allowed C programs to implicitly convert
  integers to pointers and pointers to integers, despite it not being
  valid to do so except under special circumstances (like converting the
  integer 0, which is the null pointer constant, to a pointer). In C89,
  this would result in undefined behavior per 3.3.4, and in C99 this rule
  was strengthened to be a constraint violation instead. Constraint
  violations are most often handled as an error.

  This patch changes the warning to default to an error in all C modes
  (it is already an error in C++). This gives us better security posture
  by calling out potential programmer mistakes in code but still allows
  users who need this behavior to use -Wno-error=int-conversion to retain
  the warning behavior, or -Wno-int-conversion to silence the diagnostic
  entirely.

GCC should do the same, for the same reasons. It's an error, and should not be
accepted by default in 2022.

I tried to look at how to change gcc/c/c-typeck.cc so that the pedwarns in
convert_for_assignment are errors by default, unless you use
-Wno-error=int-conversion, but I'm not sure how to make that happen.

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

end of thread, other threads:[~2023-12-01  8:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 22:55 [Bug c/106416] New: -Wint-conversion should be an error, not a pedwarn redi at gcc dot gnu.org
2022-07-25 14:16 ` [Bug c/106416] " mpolacek at gcc dot gnu.org
2022-07-27 15:43 ` fw at gcc dot gnu.org
2022-07-27 20:01 ` redi at gcc dot gnu.org
2022-07-31  8:44 ` dcb314 at hotmail dot com
2022-07-31  8:50 ` pinskia at gcc dot gnu.org
2022-07-31  8:54 ` dcb314 at hotmail dot com
2023-12-01  7:12 ` cvs-commit at gcc dot gnu.org
2023-12-01  7:15 ` fw at gcc dot gnu.org
2023-12-01  8:20 ` sjames 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).