This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60009] g++ allows copy-initialization of an array of class type from a non-braced string literal
- From: "rs2740 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Jun 2014 04:21:26 +0000
- Subject: [Bug c++/60009] g++ allows copy-initialization of an array of class type from a non-braced string literal
- Auto-submitted: auto-generated
- References: <bug-60009-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60009
TC <rs2740 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #1 from TC <rs2740 at gmail dot com> ---
http://stackoverflow.com/questions/24378882/weird-gcc-array-initialization-behavior
appears to be related.
Minimal example:
struct A { A() { } };
int main() { A a[10] = A(); }
Compiles with GCC 4.6, 4.7, 4.8 and 4.9, in both C++98 and C++11 modes, even
though it shouldn't. However,
struct A { };
int main() { A a[10] = A(); }
does not compile in any of the GCC versions tested.
struct A { A() = default; };
int main() { A a[10] = A(); }
Compiles with GCC 4.9 in C++11 mode; does not compile with 4.6-4.8 in C++ 11
mode, however.