Subject: Re: [isocpp-parallel] (SC22WG14.16350) Rough notes from SC22 WG21 SG14 meeting on pointer lifetime-end zap
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2019-05-03 03:50:12
>>> 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.
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.
SG14 list run by firstname.lastname@example.org
Older Archives on Google Groups