This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59465] g++ allows direct-initialization of an array of class type from another array in a mem-initializer
- From: "ostash at ostash dot kiev.ua" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 09 Jan 2014 16:18:53 +0000
- Subject: [Bug c++/59465] g++ allows direct-initialization of an array of class type from another array in a mem-initializer
- Auto-submitted: auto-generated
- References: <bug-59465-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59465
Viktor Ostashevskyi <ostash at ostash dot kiev.ua> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ostash at ostash dot kiev.ua
--- Comment #1 from Viktor Ostashevskyi <ostash at ostash dot kiev.ua> ---
Another test case:
static const int my_size = 10;
class UserType
{
public:
UserType(): f_(){}
private:
int f_;
};
#if 1
typedef UserType Array[my_size];
#else
typedef char Array[my_size];
#endif
class Foo
{
public:
Foo(Array& m) : m_(m) {};
private:
Array m_;
};
Target: x86_64-pc-linux-gnu
gcc version 4.8.3 20140102 (prerelease)
In case when Array is char, g++ correctly states:
error: array used as initializer
Foo(Array& m) : m_(m) {};
^
but when Array is UserType there is no error.
clang 3.4 correctly produces an error for both cases:
error: array initializer must be an initializer list or string literal
Foo(Array& m) : m_(m) {};
^
or
error: array initializer must be an initializer list
Foo(Array& m) : m_(m) {};
^