[LLVMdev] Helping the optimizer along (__assume)

Kenneth Boyd zaimoni at zaimoni.com
Thu Oct 23 12:17:28 PDT 2008


C├ędric Venet wrote:
>> Technically, yes, but we can reword future standards to have the  
>> latitude to give compilation errors for conditions that can be proved  
>> to be false, then the implementation is conforming.  We could always  
>> have a flag to control the behavior if people want/need it, though, I  
>> can't hardly see why they'd want it to compile if they assert  
>> something that is false.
>>     
>
> you never seen assert(0 && "Not yet implemented"); ?
> You may want to compile a program like this :)
>   
As I see it, under the proposed extension a compile-time false constant 
would error "if the code commits to executing it".

Heuristically, something like

void foo(int x)
{
    switch(x)
    {
    case 1: return;
    case 2: return;
    default: assert(0 && "not yet implemented")
    }
}

should itself compile, but then ideally

foo(3)

causes a compiler error as it commits to executing the assert.

Kenneth




More information about the llvm-dev mailing list