assume, assert, enforce, @safe

Daniel Gibson via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 06:44:35 PDT 2014


Am 31.07.2014 15:32, schrieb Johannes Pfau:
> Am Wed, 30 Jul 2014 17:32:10 -0700
> schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:
>
>> On 7/30/14, 5:29 PM, Andrei Alexandrescu wrote:
>>> On 7/30/14, 4:51 PM, Tobias Müller wrote:
>>>> With relatively 'dumb' compilers, this is not a big problem, but
>>>> optimizers
>>>> are more and more clever and will take profit of such assumptions
>>>> if they can.
>>>
>>> That's true, and it seems like a growing trend. Relevant threads:
>>>
>>> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/9S5jNRW-5wY
>>>
>>>
>>> http://www.spinics.net/lists/gcchelp/msg41714.html
>>>
>>> Recent versions of gcc and clang have become increasingly aggressive
>>> about optimizing code by taking advantage of making undefined
>>> behavior _really_ undefined. There's been a couple of posts in the
>>> news recently that I can't find at the moment.
>>
>> I think I found it: http://www.redfelineninja.org.uk/daniel/?p=307
>>
>> Andreu
>>
>
> Also this:
>
> Linus Torvalds On GCC 4.9: Pure & Utter Crap
> http://www.phoronix.com/scan.php?page=news_item&px=MTc1MDQ
>
> (This actually is a GCC bug, but valid behaviour for normal C++ code.
> GCC only broke the compiler switch to explicitly force non-standard
> behaviour)
>

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.)

Cheers,
Daniel


More information about the Digitalmars-d mailing list