[PATCH] D21701: [AMDGPU] Fix warning
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 15:25:14 PDT 2016
kzhuravl added a comment.
I am getting this warning when building without `default`:
/home/kzhuravl/Lightning/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp: In function â?~SIEncodingFamily subtargetEncodingFamily(const llvm::AMDGPUSubtarget&)â?T:
/home/kzhuravl/Lightning/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp:160:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
I am not getting a warning with `default`, which makes sense to me.
Underlying type of an unscoped enum is some integral type (int, unsigned int, etc... implementation-defined). So, I do not think, that switching over all defined enum values is enough:
- What happens if, for some reason, `ST.getGeneration()` returns an undefined enum value (for example, some garbage)? - undefined behavior.
- What happens if we add a new enum value, and forget to add it to a switch statement? - undefined behavior.
Someone can argue that above 2 cases can never happen, hence it is a warning, not a compilation error. But I'd rather know that unreachable will be executed if something goes wrong.
Please, correct me if I am wrong.
I am not sure why you experience the reverse behavior. Do you have any other modified files? Can you paste the warning you are getting?
http://reviews.llvm.org/D21701
More information about the llvm-commits
mailing list