* Marek Polacek:

> On Thu, Nov 10, 2022 at 07:25:21PM +0100, Florian Weimer via Gcc wrote:
>> GCC accepts various conversions between pointers and ints and different
>> types of pointers by default, issuing a warning.
>> 
>> I've been reading the (hopefully) relevant partso f the C99 standard,
>> and it seems to me that C implementations are actually required to
>> diagnose errors in these cases because they are constraint violations:
>> the types are not compatible.
>
> It doesn't need to be a hard error, a warning is a diagnostic message,
> which is enough to diagnose a violation of any syntax rule or
> constraint.
>
> IIRC, the only case where the compiler _must_ emit a hard error is for
> #error.

Hmm, you could be right.

The standard says that constraint violations are not undefiend behavior,
but of course it does not define what happens in the presence of a
constraint violation.  So the behavior is undefined by omission.  This
seems to be a contradiction.

I assumed that there was a rule similar to the the rule for #error for
any kind of diagnostic, which would mean that GCC errors are diagnostic
messages in the sense of the standard, but GCC warnings are not.

I wonder how C++ handles this.

Thanks,
Florian

Reply via email to