assume, assert, enforce, @safe

Artur Skawina via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 12:43:46 PDT 2014


On 07/31/14 19:22, John Colvin via Digitalmars-d wrote:
> On Thursday, 31 July 2014 at 15:26:27 UTC, Artur Skawina via Digitalmars-d wrote:
>> On 07/31/14 15:44, Daniel Gibson via Digitalmars-d wrote:
>>> And don't forget this (rather old) case: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537
>>> (I really don't get why anyone would want such an optimization: I want an optimizer to use clever inlining, use SSE etc where it makes sense and stuff like that - but not to remove code I wrote.)
>>
>> That is actually not a bug, but a perfectly valid optimization. The
>> compiler isn't clairvoyant and can not know that some data that you
>> wrote, but never read back, matters.

> Any idea how dead store removal interacts with the modern C(++) memory model? Another thread could hold a reference to the memory being written to.

In case of local/stack and TLS objects the compiler can often prove that
there are no other refs (eg because the address is never escaped).

artur


More information about the Digitalmars-d mailing list