Am Fr., 15. Dez. 2023 um 02:00 Uhr schrieb Paul Eggert <egg...@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 -- [1] https://mohitmv.github.io/blog/Shocking-Undefined-Behaviour-In-Action/ [2] https://en.wikipedia.org/wiki/Principle_of_explosion