[llvm-bugs] [Bug 50641] New: Valid combination of "constexpr", "[[unlikely]]" and switch statement leads to "error: no return statement in constexpr function"
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 9 06:27:51 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50641
Bug ID: 50641
Summary: Valid combination of "constexpr", "[[unlikely]]" and
switch statement leads to "error: no return statement
in constexpr function"
Product: clang
Version: 12.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: treh at think-cell.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
The following code fails to compile in clang++ 12
https://godbolt.org/z/eGM93Tqcr
constexpr
char Test(int n) {
switch( n )
[[unlikely]] default: {
case 0: return 'a';
case 1: return 'b';
}
}
with the message:
<source>:3:6: error: no return statement in constexpr function
Even if it seems odd at first sight, this is valid C++ and compiles on latest
gcc https://godbolt.org/z/8YGfM3dM8
and MSVC https://godbolt.org/z/MP7YaP5qv
It is actually part of our production codebase, used there to implement a
"switch_no_default"-macro that asserts if a value occurs that's not among the
"cases".
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210609/c143f76d/attachment.html>
More information about the llvm-bugs
mailing list