[llvm-bugs] [Bug 31624] New: static method invocation via objects are not considered constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 12 17:36:05 PST 2017


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

            Bug ID: 31624
           Summary: static method invocation via objects are not
                    considered constexpr
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matt at godbolt.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider the following (unusual) code:

struct Foo { static constexpr bool hasBar() { return true; } };

void test(const Foo &f) {
  static_assert(Foo::hasBar(), ""); // -is ok
  static_assert(f.hasBar(), ""); // fails on clang trunk 291576, works in GCC
}

(also on https://godbolt.org/g/qwzYvc )

All clang versions I tested it on fail with "error: static_assert expression is
not an integral constant expression". GCC and CL both allow this and consider
the call to the static method hasBar via the actual object f to be constexpr.

It's not clear to me which behaviour is correct, though instinctively I'd
imagine it to be valid to allow such calls as constexpr.

-- 
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/20170113/550863a5/attachment.html>


More information about the llvm-bugs mailing list