This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patch for bug with new-initializers
- To: sl at psycode dot com
- Subject: Patch for bug with new-initializers
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Tue, 10 Mar 1998 23:34:49 -0800
- Cc: egcs-bugs at cygnus dot com
- Reply-to: mmitchell at usa dot net
Here's a patch for code like this:
void f()
{
new int = 1;
}
This GNU extension didn't work at all. Jason, may I check this in
with a testcase?
BTW, I am very dubious of GNU extensions (such as implicit typename,
these extended new-initializers, labeled initializers) and so forth,
because they seem to cause quite a few bugs, are not tested often
enough, and add complexity when trying to work on the C++ front-end.
They also create noise on the list; when deciding whether to fix a
problem or not, I have to figure out whether it's one I care about,
and I generally don't care about these extensions. However, I do want
the compiler to be crash-proof on *all* inputs, even invalid ones.
Life would be simpler if these crashes simply resulted in error
messages when the extension was attempted; then users would better
understand what is going on.
I suggest disabling some of these (perhaps the set I mentioned above)
by default; an error message is better than a crash. They could be
enabled by individual switches by interested parties. What do y'all
think of this idea?
--
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available
Tue Mar 10 23:23:20 1998 Mark Mitchell <mmitchell@usa.net>
* parse.y (new_initializer): Make sure all initializers are
lists.
Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/parse.y,v
retrieving revision 1.39
diff -c -p -r1.39 parse.y
*** parse.y 1998/03/02 12:22:31 1.39
--- parse.y 1998/03/11 07:30:44
*************** new_initializer:
*** 1217,1223 ****
{
if (pedantic)
pedwarn ("ANSI C++ forbids initialization of new expression with `='");
! $$ = $2;
}
;
--- 1217,1226 ----
{
if (pedantic)
pedwarn ("ANSI C++ forbids initialization of new expression with `='");
! if (TREE_CODE ($2) != TREE_LIST)
! $$ = build_expr_list (NULL_TREE, $2);
! else
! $$ = $2;
}
;