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.