assume, assert, enforce, @safe

Andrew Godfrey via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 10:01:37 PDT 2014


On Thursday, 31 July 2014 at 16:37:40 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> On Thu, Jul 31, 2014 at 03:44:35PM +0200, 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.)
> [...]
>
> Modern compilers often have to deal with generated code (that 
> isn't
> directly written by the programmer, e.g., expanded from a C++ 
> template
> -- or, for that matter, generated by a code generator like lex 
> / yacc).
> In this case, you *do* want dead code removal because the code 
> generator
> may be written in a way that takes care of the general case, 
> but in your
> specific case some of the generated code is redundant.  You 
> don't want
> to penalize specific instances of the generic code pattern, 
> after all.

Both points of view make sense. The problem is that it's hard for 
the compiler to know when the code it elides was generated code 
or explicitly written. (Maybe this is solvable in dmd,  I don't 
know. But it's not a feature I've seen before.)




More information about the Digitalmars-d mailing list