[LLVMbugs] [Bug 14428] New: clang instantiates arguments of all constructors in presence of constructor with default argument

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 23 14:32:09 PST 2012


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

             Bug #: 14428
           Summary: clang instantiates arguments of all constructors in
                    presence of constructor with default argument
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu,
                    richard-llvm at metafoo.co.uk
    Classification: Unclassified


>From r168521:

  template <typename T> struct move_from {
    T invalid;
  };
  template <class K>
  struct unordered_map {
    explicit unordered_map(int n = 42);
    unordered_map(move_from<K> other);
  };
  template<typename T>
  void StripedHashTable() {
    new unordered_map<void>();
  }
  void tt() {
    StripedHashTable<int>();
  }

clang instantiates move_from<void> and emits an error. GCC and EDG accept this
code, so does the clang 3.0 from llvm.org/demo.

r168521 can probably be reverted when this is fixed.

Richard says:
> Looking just at what you needed to change in your patch, my wild guess
> is that we might be trying to initialize an unordered_map object from
> the default argument expression '42', rather than trying to initialize
> the 'n' parameter of the explicit constructor from it. That would
> explain why we instantiate move_from<K>: we'd be trying to use the
> second constructor to convert '42' to an unordered_map, but would be a
> very surprising bug to have...

-- 
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