[LLVMbugs] [Bug 23381] New: "error: default initialization of an object of const type 'const Z' requires a user-provided default constructor" even when no constructor needed.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 30 04:29:04 PDT 2015


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

            Bug ID: 23381
           Summary: "error: default initialization of an object of const
                    type 'const Z' requires a user-provided default
                    constructor" even when no constructor needed.
           Product: compiler-rt
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: daniel.black at openquery.com.au
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

"error: default initialization of an object of const type 'const Z' requires a
user-provided default constructor" even when no constructor needed.

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253

$ cat  >  /tmp/x.cc
  struct Z {
        // no data members
        operator int() const { return 0; }
    };

    void f() {
        const Z z1;         // ill-formed: no initializer
        const Z z2 = { };   // well-formed
    }


$ clang++ -c /tmp/x.cc
/tmp/x.cc:7:17: error: default initialization of an object of const type 'const
Z' requires a user-provided default constructor
        const Z z1;         // ill-formed: no initializer
                ^
1 error generated.

g++ compiles without error

clang++ --version

clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix

g++ (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- 
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/20150430/f9b5c3a4/attachment.html>


More information about the llvm-bugs mailing list