[llvm-bugs] [Bug 41896] New: Bogus "error: no return statement in constexpr function" when void return type is "templated"

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 16 02:17:07 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41896

            Bug ID: 41896
           Summary: Bogus "error: no return statement in constexpr
                    function" when void return type is "templated"
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stephan.bergmann.secondary at googlemail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

At least since Clang 5.0 (couldn't easily check back further) and still with
recent Clang trunk:

$ cat test.cc
> #include <type_traits>
> constexpr void f() {}
> constexpr std::enable_if<true, void> g() {}

$ clang++ -fsyntax-only -std=c++17 test.cc 
> test.cc:3:38: error: no return statement in constexpr function
> constexpr std::enable_if<true, void> g() {}
>                                      ^
> 1 error generated.

That is, it doesn't fail for f but only for g, and I don't find anything in
C++17 [dcl.constexpr] that requires a return statement, so I assume the error
is bogus?

(I ran into this in some scenario with GCC libstdc++ after
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a858e2a4ea80631a88a5a1e351389236e3f35bc1>
"Define std::__invoke_r for INVOKE<R>", which added a similar
__can_invoke_as_void<...> __invoke_r(...) to
libstdc++-v3/include/bits/inovke.h.)

-- 
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/20190516/52f486e9/attachment.html>


More information about the llvm-bugs mailing list