bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pointer addition and arrays


From: Marc Nieper-Wißkirchen
Subject: Re: pointer addition and arrays
Date: Sat, 16 Dec 2023 13:42:44 +0100

Am Fr., 15. Dez. 2023 um 02:00 Uhr schrieb Paul Eggert <eggert@cs.ucla.edu>:
On 12/3/23 05:15, Andreas F. Borchert wrote:
> You will have
> then to possibly live with annoying warnings and odd behaviours.

The C standard says that when P is a null pointer, P==P must be true
whereas P<=P has undefined behavior. However, in practice any
implementation where P==P succeeds but P<=P fails is a pedantic
implementation that is merely enforcing what are arguably bugs in the
standard. Let's not waste time worrying about implementations like that.

I would agree if implementations did this because of pedantry, just because.  But the problem is if further down in the compiler pipeline, the P <= P _expression_ produces some intermediate code that becomes equal to code the optimizer should rightfully optimize away (or replace by the equivalent of __builtin_unreachable).

Gnulib should lead by example and follow the standard (on systems that implement the standard.  I like Example 2 on this page [1] very much.  It shows that well-justified optimizations can easily lead to consequences of UB that make the compiler look evil (or pedantic).  We cannot circumvent the principle of explosion ([2]).

Thanks,

Marc

--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]