* 971127 array initialization problem!?!
@ 1997-11-30 7:17 neal
1997-11-30 14:29 ` Alexandre Oliva
1997-11-30 23:52 ` Lassi A. Tuura
0 siblings, 2 replies; 5+ messages in thread
From: neal @ 1997-11-30 7:17 UTC (permalink / raw)
To: egcs
This trivial test program seems to show a serious problem with array
initialization in g++ egcs-971127 (or has something changed in recent
c++ that I'm not aware of?)
struct QBitmap {
QBitmap (int,int, bool=false);
};
main () {
QBitmap* x = new QBitmap(2,2);
QBitmap* y = new QBitmap[5](2,2);
}
g++ -c Test.c
Test.c: In function `int main()':
Test.c:9: no matching function for call to `QBitmap::QBitmap (int)'
Test.c:5: candidates are: QBitmap::QBitmap(const QBitmap &)
Test.c:4: QBitmap::QBitmap(int, int, bool)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 971127 array initialization problem!?!
1997-11-30 7:17 971127 array initialization problem!?! neal
@ 1997-11-30 14:29 ` Alexandre Oliva
1997-11-30 23:52 ` Lassi A. Tuura
1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 1997-11-30 14:29 UTC (permalink / raw)
To: neal; +Cc: egcs
writes:
> This trivial test program seems to show a serious problem with array
> initialization in g++ egcs-971127 (or has something changed in recent
> c++ that I'm not aware of?)
C++ has never allowed initialization of dynamically constructed arrays
with non-default constructors. The error message is misleading.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 971127 array initialization problem!?!
1997-11-30 7:17 971127 array initialization problem!?! neal
1997-11-30 14:29 ` Alexandre Oliva
@ 1997-11-30 23:52 ` Lassi A. Tuura
1997-12-01 2:46 ` Robert Wilhelm
1 sibling, 1 reply; 5+ messages in thread
From: Lassi A. Tuura @ 1997-11-30 23:52 UTC (permalink / raw)
To: neal; +Cc: egcs
neal@ctd.comsat.com wrote:
> QBitmap* y = new QBitmap[5](2,2);
This is not valid C++ syntax -- initialisers are not allowed in
array-new expression. Code like this used to compile with g++, but I
don't know if it ever was officially supported GNU extension. If the
feature has been removed, the diagnostic could be improved...
Cheers,
//lat
--
Lassi.Tuura@cern.ch There's no sunrise without a night
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 971127 array initialization problem!?!
1997-11-30 23:52 ` Lassi A. Tuura
@ 1997-12-01 2:46 ` Robert Wilhelm
1997-12-01 11:32 ` Joe Buck
0 siblings, 1 reply; 5+ messages in thread
From: Robert Wilhelm @ 1997-12-01 2:46 UTC (permalink / raw)
To: Lassi A. Tuura; +Cc: neal, egcs, g++
On Mon, Dec 01, 1997 at 08:52:19AM +0100, Lassi A. Tuura wrote:
> neal@ctd.comsat.com wrote:
> > QBitmap* y = new QBitmap[5](2,2);
>
> This is not valid C++ syntax -- initialisers are not allowed in
> array-new expression. Code like this used to compile with g++, but I
> don't know if it ever was officially supported GNU extension. If the
> feature has been removed, the diagnostic could be improved...
>
Would the g++ maintainers accept patches to restore the old behavior?
I have quite a lot of code which depends on
this unofficial behavior :-(
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 971127 array initialization problem!?!
1997-12-01 2:46 ` Robert Wilhelm
@ 1997-12-01 11:32 ` Joe Buck
0 siblings, 0 replies; 5+ messages in thread
From: Joe Buck @ 1997-12-01 11:32 UTC (permalink / raw)
To: Robert Wilhelm; +Cc: Lassi.Tuura, neal, egcs, g++
> On Mon, Dec 01, 1997 at 08:52:19AM +0100, Lassi A. Tuura wrote:
> > neal@ctd.comsat.com wrote:
> > > QBitmap* y = new QBitmap[5](2,2);
> >
> > This is not valid C++ syntax -- initialisers are not allowed in
> > array-new expression. Code like this used to compile with g++, but I
> > don't know if it ever was officially supported GNU extension. If the
> > feature has been removed, the diagnostic could be improved...
> >
>
> Would the g++ maintainers accept patches to restore the old behavior?
>
> I have quite a lot of code which depends on
> this unofficial behavior :-(
I would advise against it. g++ can't carry baggage forever. I'd like
for us to encourage people to write C++ and do a good job compiling it,
rather than encourage them to write a different language called "g++".
As for your "quite a lot of code", use vectors to get the same effect:
vector<QBitmap> y(5, QBitmap(2,2));
If you must have C arrays, you could use placement new to do the
construction.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-12-01 11:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-30 7:17 971127 array initialization problem!?! neal
1997-11-30 14:29 ` Alexandre Oliva
1997-11-30 23:52 ` Lassi A. Tuura
1997-12-01 2:46 ` Robert Wilhelm
1997-12-01 11:32 ` Joe Buck
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).