public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43453] New: Initialization of char array with string literal fails in mem-initializer
@ 2010-03-20 3:06 schaub-johannes at web dot de
2010-08-27 18:06 ` [Bug c++/43453] " giecrilj at stegny dot 2a dot pl
2010-08-28 14:40 ` schaub-johannes at web dot de
0 siblings, 2 replies; 3+ messages in thread
From: schaub-johannes at web dot de @ 2010-03-20 3:06 UTC (permalink / raw)
To: gcc-bugs
Fails to compile, but should work:
struct A {
char x[4];
A():x("bug") { }
};
Error i get is:
"main.cpp:3: error: array used as initializer"
--
Summary: Initialization of char array with string literal fails
in mem-initializer
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: schaub-johannes at web dot de
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43453
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/43453] Initialization of char array with string literal fails in mem-initializer
2010-03-20 3:06 [Bug c++/43453] New: Initialization of char array with string literal fails in mem-initializer schaub-johannes at web dot de
@ 2010-08-27 18:06 ` giecrilj at stegny dot 2a dot pl
2010-08-28 14:40 ` schaub-johannes at web dot de
1 sibling, 0 replies; 3+ messages in thread
From: giecrilj at stegny dot 2a dot pl @ 2010-08-27 18:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from giecrilj at stegny dot 2a dot pl 2010-08-27 18:06 -------
(In reply to comment #0)
> Fails to compile, but should work:
>
> struct A {
> char x[4];
> A():x("bug") { }
> };
>
> Error i get is:
>
> "main.cpp:3: error: array used as initializer"
>
Why do you think it should work?
For example, the following equivalent code is invalid as well:
char x [4] ("bug");
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43453
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/43453] Initialization of char array with string literal fails in mem-initializer
2010-03-20 3:06 [Bug c++/43453] New: Initialization of char array with string literal fails in mem-initializer schaub-johannes at web dot de
2010-08-27 18:06 ` [Bug c++/43453] " giecrilj at stegny dot 2a dot pl
@ 2010-08-28 14:40 ` schaub-johannes at web dot de
1 sibling, 0 replies; 3+ messages in thread
From: schaub-johannes at web dot de @ 2010-08-28 14:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from schaub-johannes at web dot de 2010-08-28 14:39 -------
(In reply to comment #1)
> (In reply to comment #0)
> > Fails to compile, but should work:
> >
> > struct A {
> > char x[4];
> > A():x("bug") { }
> > };
> >
> > Error i get is:
> >
> > "main.cpp:3: error: array used as initializer"
> >
>
> Why do you think it should work?
> For example, the following equivalent code is invalid as well:
>
> char x [4] ("bug");
>
This code is equivalent and is valid. At least, I don't see the Standard
forbidding it. GCC is the only compiler I tested (comeau/edg, clang) that
rejects it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43453
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-28 14:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-20 3:06 [Bug c++/43453] New: Initialization of char array with string literal fails in mem-initializer schaub-johannes at web dot de
2010-08-27 18:06 ` [Bug c++/43453] " giecrilj at stegny dot 2a dot pl
2010-08-28 14:40 ` schaub-johannes at web dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).