[LLVMbugs] [Bug 13080] New: Invalid but unused NSDMI is not ignored

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 11 09:18:39 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13080

             Bug #: 13080
           Summary: Invalid but unused NSDMI is not ignored
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: zilla at kayari.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I couldn't find anything in the standard about when a NSDMI in a template is
instantiated, but I'm pretty sure it's never needed here and this should
compile:

template<typename T>
struct A
{
    A() = default;
    A(T t) : t(t) { }
    T t{ T() };
};

struct NotDefaultConstructible
{
    NotDefaultConstructible(int) { }
};

A<NotDefaultConstructible> a( NotDefaultConstructible(0) );

The default constructor (which would use the NSDMI) is never odr-used so should
not be defined. Even if the default constructor is removed clang++ still
rejects the code.

G++ accepts this code and I was hoping to use something like it in libstdc++
but that would cause problems for people using libstdc++ with clang++.

Naïvely I would expect this to have the same semantics as:

template<typename T>
struct A
{
    A(T t = T()) : t(t) { }
    T t;
};

In this case the default argument is only implicitly instantiated when the
constructor is called in a context that requires it.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list