C++ Logo


Advanced search

Re: [SG14] [isocpp-parallel] (SC22WG14.16350) Rough notes from SC22 WG21 SG14 meeting on pointer lifetime-end zap

From: Niall Douglas <s_sourceforge_at_[hidden]>
Date: Fri, 3 May 2019 09:50:12 +0100
>>> T *a = new T;
>>> delete a;
>>> T *b = new T;
>>> // Everybody agrees the compiler can assume this is always true
>>> assert(a != b);
>> I'm not at all sure this is right. The compiler can definitely assume that
>> *a and *b do not alias; falsifying that would involve dereferences which
>> would result in undefined behavior. And disallowing that assumption would
>> slow down code. But that's not really exposed to the user, and not the same
>> thing as claiming a!=b is true.
> y

As I already explained with code snippets in previous emails, clang
already hard assumes the above comparison is always true. I'll relink my
godbolt example: https://godbolt.org/z/c219s9

This is because, as Richard Smith already explained, clang already does
provenance tracking, and its rules lead to the above result.

Given that production compilers are already shipping and making these
kinds of provenance-based optimisations, if those rules mathematically
lead to incorrect codegen, then I'd say it's urgent to get clang fixed.


Received on 2019-05-03 03:52:12