[LLVMbugs] [Bug 12091] New: Problems with nested initializer list
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Feb 26 11:59:31 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12091
Bug #: 12091
Summary: Problems with nested initializer list
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: janski.krzysztof at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
For the code:
---
struct A
{
int a;
public:
A(int a): a(a) {}
};
struct B1
{
B1(const A& a): a(a) {}
A a;
};
struct B2
{
A a;
};
int main()
{
B1 b1 {{1}};
B2 b2 {{2}};
return 0;
}
---
I got the following output from clang (user path replaced with $HOME):
---
$ clang++ -v -std=c++0x initializer_list.cpp
clang version 3.1 (http://llvm.org/git/clang.git
ea7c1e24f33c554aeac07dc4f6dc7493dd98e272)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"$HOME/sysroot/opt/clang/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
initializer_list.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64
-momit-leaf-frame-pointer -v -resource-dir
$HOME/sysroot/opt/clang/bin/../lib/clang/3.1 -fmodule-cache-path
/var/tmp/clang-module-cache -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward
-internal-isystem /usr/local/include -internal-isystem
$HOME/sysroot/opt/clang/bin/../lib/clang/3.1/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++0x -fdeprecated-macro
-fdebug-compilation-dir $HOME/tmp -ferror-limit 19 -fmessage-length 0
-mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak
-fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o
/tmp/initializer_list-5Fzphb.o -x c++ initializer_list.cpp
clang -cc1 version 3.1 based upon LLVM 3.1svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward
/usr/local/include
$HOME/sysroot/opt/clang/bin/../lib/clang/3.1/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
initializer_list.cpp:21:5: error: call to constructor of 'B1' is ambiguous
B1 b1 {{1}};
^ ~~~~~
initializer_list.cpp:8:8: note: candidate is the implicit move constructor
struct B1
^
initializer_list.cpp:8:8: note: candidate is the implicit copy constructor
initializer_list.cpp:10:2: note: candidate constructor
B1(const A& a): a(a) {}
^
initializer_list.cpp:22:9: error: initialization of non-aggregate type 'A' with
an initializer list
B2 b2 {{2}};
^~~
2 errors generated.
---
The code compiles with gcc 4.6.2. Unfortunately I'm not familiar enough with
C++11 to say which compiler is right, I suppose gcc.
--
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