[Development] Compiler warnings
    Thiago Macieira 
    thiago.macieira at intel.com
       
    Fri Oct 17 18:31:00 CEST 2014
    
    
  
On Friday 17 October 2014 13:06:39 Milian Wolff wrote:
> enum Foo {
> Bar = 1, Baz = 2
> };
> 
> Foo foo = static_cast<Foo>(3);
> 
> Now what do you do without a default clause?
Shoot the developer who abused the API.
If the function accepts enum values 1 and 2 and you pass a 3, you deserve the 
undefined behaviour.
That is the same as passing a bool that doesn't contain exactly values 0 or 1 
or passing an uninitialised pointer.
We have to handle all regular conditions. We don't have to guard against 
stupidity.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
    
    
More information about the Development
mailing list