More C type errors by default for GCC 14

Florian Weimer fw@deneb.enyo.de
Fri May 12 21:59:08 GMT 2023


* Sam James:

> Florian Weimer <fw@deneb.enyo.de> writes:
>
>> * Sam James:
>>
>>> Florian Weimer <fw@deneb.enyo.de> writes:
>>>
>>>> [...]
>>>> In summary, all these seems to be good candidates for errors by default:
>>>>
>>>> * int-conversion as errors (already raised separately
>>>> * -Wint-conversion for ?:
>>>> * parameter names in non-prototype function declarations
>>>> * the union wait function pointer compatibility kludge
>>>> * return-with-out-value for non-void functions
>>>> * -Wincomatible-pointer-types warning for ?: (but no error yet, see below)
>>>>
>>>> This are more “maybe“:
>>>>
>>>> * incompatible-pointer-types as errors (already raised separately)
>>>> * int-conversion and incompatible-pointer-types in comparisons
>>>> * return with value in a function returning void
>>>
>>> -Wreturn-type tends to bite people with C++.
>>
>> Sorry, what do you mean?
>
> Falling off the end of a function in C++ is UB and people fall
> victim to it often, but in C, it's only UB if you try to use
> its return value.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 is one
> example of many.
>
> What I meant was: I see this a lot in C++ and sometimes in C
> but it's usually trivial to fix, even if it's less harmful
> for some of the instances.

Ohh, I was thinking just about the -Wreturn-type issues for return
statements (value vs no value), not “control reaches end of non-void
function”.  That's a separate issue, and yes, it's more confusing for
C++ due to undefined behavior back-propagation within the same
function.


More information about the Gcc mailing list