[llvm-bugs] [Bug 42980] New: Conditional explicit not respected with out-of-line definition

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 12 13:28:20 PDT 2019


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

            Bug ID: 42980
           Summary: Conditional explicit not respected with out-of-line
                    definition
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: barry.revzin at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Reduced from StackOverflow (https://stackoverflow.com/q/57467490/2069064):

using size_t = decltype(sizeof(0));

struct Str {
    template <size_t N>
    explicit(N > 7) Str(char const (&str)[N]);
};

#ifdef OUT_OF_LINE
template <size_t N>
Str::Str(char const(&str)[N]) { }
#endif

Str a = "short";
Str b = "not so short";

As-is, clang correctly rejects the construction of b (since that constructor is
explicit). But with -DOUT_OF_LINE, clang accepts.

-- 
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/20190812/3655e683/attachment.html>


More information about the llvm-bugs mailing list