[lld] r179590 - Moved llvm_unreachable out of switch blocks to avoid the "control reaches end of non-void function" warning.

Andy Gibbs andyg1001 at hotmail.co.uk
Tue Apr 16 09:59:32 PDT 2013


On Tuesday, April 16, 2013 6:34 PM, Nick Kledzik wrote:

> What compiler is issuing the warning?  llvm_unreachable() is
> designed to look like a no-return function, so that compilers
> will not issue that warning.
>
> -Nick

gcc produces this warning, since the enum value in the switch statement 
"may" be any value, not necessarily one of the proper values, and so 
execution can reach beyond the end of the switch block.  Personally I think 
clang should also produce a warning in this case.

(Its covered, rather more elegantly, as a subscript to 
http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations)

Cheers
Andy




More information about the llvm-commits mailing list