public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17023] New: ICE with nested functions in parameter declaration
@ 2004-08-14  0:12 jsm28 at gcc dot gnu dot org
  2004-08-14  2:19 ` [Bug c/17023] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2004-08-14  0:12 UTC (permalink / raw)
  To: gcc-bugs

While converting the C front end to use proper structures instead of
trees for declarators, I came up with the following testcase which
ICEs with CVS mainline and most other GCC versions I tried it with.
(With 2.95.3, 2.7.2.3 and EGCS 1.0.3a, instead it gives bogus errors.)
The code is undoubtedly invalid, but no compiler version rejects it
with a meaningful error.  (I might look into this later.)

void
f(a, b)
     int a;
     int b[({ void h() {} 1; })];
{
}

nested-func-mess.c: In function `f':
nested-func-mess.c:4: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Nested functions clearly should not be allowed outside the body of a
function.

-- 
           Summary: ICE with nested functions in parameter declaration
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/3.5 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
@ 2004-08-14  2:19 ` pinskia at gcc dot gnu dot org
  2004-08-14  2:27 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-14  2:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-14 02:19 -------
Confirned, considered a regression because of the ICE.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-invalid-code
      Known to fail|                            |3.0.4 3.3.3 3.2.3 3.4.0
                   |                            |3.5.0
      Known to work|                            |2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-14 02:19:05
               date|                            |
            Summary|ICE with nested functions in|[3.3/3.4/3.5 Regression] ICE
                   |parameter declaration       |with nested functions in
                   |                            |parameter declaration
   Target Milestone|---                         |3.4.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/3.5 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
  2004-08-14  2:19 ` [Bug c/17023] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-14  2:27 ` pinskia at gcc dot gnu dot org
  2004-08-29 18:06 ` mmitchel at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-14  2:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-14 02:27 -------
ICEing since at least 2000-12-31.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdr at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/3.5 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
  2004-08-14  2:19 ` [Bug c/17023] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
  2004-08-14  2:27 ` pinskia at gcc dot gnu dot org
@ 2004-08-29 18:06 ` mmitchel at gcc dot gnu dot org
  2004-10-14 18:08 ` [Bug c/17023] [3.3/3.4/4.0 " rth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 18:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-29 18:06 -------
Postponed all ice-on-invalid bugs to GCC 3.4.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.2                       |3.4.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-08-29 18:06 ` mmitchel at gcc dot gnu dot org
@ 2004-10-14 18:08 ` rth at gcc dot gnu dot org
  2004-10-14 18:25 ` jsm at polyomino dot org dot uk
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-10-14 18:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-10-14 18:08 -------
Looks to me as if the nested function has nothing to do with it.  Rather, 
it's the statement expression.  Just "int b[({ 1; })]" is enough to crash.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rth at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-10-14 18:08 ` [Bug c/17023] [3.3/3.4/4.0 " rth at gcc dot gnu dot org
@ 2004-10-14 18:25 ` jsm at polyomino dot org dot uk
  2004-10-14 19:55 ` rth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-10-14 18:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-14 18:25 -------
Subject: Re:  [3.3/3.4/4.0 Regression] ICE with nested functions
 in parameter declaration

On Thu, 14 Oct 2004, rth at gcc dot gnu dot org wrote:

> Looks to me as if the nested function has nothing to do with it.  Rather, 
> it's the statement expression.  Just "int b[({ 1; })]" is enough to crash.

I think the plain statement expression case is actually valid code (the 
statement expression should be evaluated on function entry just like the 
other array size expressions in the parameters).



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-10-14 18:25 ` jsm at polyomino dot org dot uk
@ 2004-10-14 19:55 ` rth at gcc dot gnu dot org
  2004-10-14 20:05 ` jsm at polyomino dot org dot uk
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-10-14 19:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-10-14 19:55 -------
You do?  Hm, in which case I may need to persue a different solution than 
the one I'm currently testing.  Also, if true, I don't see why a nested
function wouldn't be acceptable there:

  int b[({ int h() { return 1; } h(); })]

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-10-14 19:55 ` rth at gcc dot gnu dot org
@ 2004-10-14 20:05 ` jsm at polyomino dot org dot uk
  2004-10-14 20:12 ` jsm at polyomino dot org dot uk
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-10-14 20:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-14 20:05 -------
Subject: Re:  [3.3/3.4/4.0 Regression] ICE with nested functions
 in parameter declaration

On Thu, 14 Oct 2004, rth at gcc dot gnu dot org wrote:

> You do?  Hm, in which case I may need to persue a different solution than 
> the one I'm currently testing.  Also, if true, I don't see why a nested
> function wouldn't be acceptable there:
> 
>   int b[({ int h() { return 1; } h(); })]

Perhaps you can make nested functions work there, but they seem very 
dubious when not actually within a function body.  Whereas since array 
size expressions can include calls to other functions, or recursively to 
the same function, or indeed jump out of the evaluation of array size 
expressions with longjmp, statement expressions seem more reasonable there 
(though if they attempt to jump into the body of the function that might 
be problematic).



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-10-14 20:05 ` jsm at polyomino dot org dot uk
@ 2004-10-14 20:12 ` jsm at polyomino dot org dot uk
  2004-10-14 21:09 ` rth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-10-14 20:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-14 20:12 -------
Subject: Re:  [3.3/3.4/4.0 Regression] ICE with nested functions
 in parameter declaration

On Thu, 14 Oct 2004, jsm at polyomino dot org dot uk wrote:

> expressions with longjmp, statement expressions seem more reasonable there 
> (though if they attempt to jump into the body of the function that might 
> be problematic).

Actually, given that we disallow statement expressions in prototypes 
outside a function (even where they only mean [*] and have no further 
significance) perhaps it does make sense to be stricter about saying that 
old-style parameter declarations don't count as inside a function for this 
purpose, and disallowing statement expressions there in general.  But if 
we do that then we should consider if declarations of parameters to nested 
functions likewise are restricted and can't include statement expressions.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-10-14 20:12 ` jsm at polyomino dot org dot uk
@ 2004-10-14 21:09 ` rth at gcc dot gnu dot org
  2004-10-14 23:13 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-10-14 21:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-10-14 21:09 -------
Hum.  That is a good point about this patch only mattering for K&R function
definitions.  In which case I don't really care at all, and so we should 
probably just go with the first choice to disallow stmt exprs here.

That also lets me fix 3.4 with an absolute minimum of effort, which is happy.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2004-10-14 21:09 ` rth at gcc dot gnu dot org
@ 2004-10-14 23:13 ` cvs-commit at gcc dot gnu dot org
  2004-10-14 23:21 ` cvs-commit at gcc dot gnu dot org
  2004-10-14 23:25 ` rth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-14 23:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-14 23:13 -------
Subject: Bug 17023

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	rth@gcc.gnu.org	2004-10-14 23:12:53

Modified files:
	gcc            : ChangeLog c-parse.in 

Log message:
	PR c/17023
	* c-parse.in (compstmt_primary_start): Check last_tree non-null,
	not current_function_decl non-null.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.661&r2=2.2326.2.662
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-parse.in.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.194.2.5&r2=1.194.2.6



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2004-10-14 23:13 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-14 23:21 ` cvs-commit at gcc dot gnu dot org
  2004-10-14 23:25 ` rth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-14 23:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-14 23:21 -------
Subject: Bug 17023

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-10-14 23:20:58

Modified files:
	gcc            : ChangeLog c-decl.c c-parse.in 
Added files:
	gcc/testsuite/gcc.dg: 20041014-1.c 

Log message:
	PR c/17023
	* c-decl.c (store_parm_decls_oldstyle): Care for parameter type
	as error_mark_node.
	* c-parse.in (compstmt_primary_start): Check cur_stmt_list non-null
	instaed of current_function_decl non-null.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5889&r2=2.5890
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.601&r2=1.602
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-parse.in.diff?cvsroot=gcc&r1=1.247&r2=1.248
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20041014-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c/17023] [3.3/3.4/4.0 Regression] ICE with nested functions in parameter declaration
  2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2004-10-14 23:21 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-14 23:25 ` rth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-10-14 23:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-10-14 23:25 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17023


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-10-14 23:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-14  0:12 [Bug c/17023] New: ICE with nested functions in parameter declaration jsm28 at gcc dot gnu dot org
2004-08-14  2:19 ` [Bug c/17023] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-14  2:27 ` pinskia at gcc dot gnu dot org
2004-08-29 18:06 ` mmitchel at gcc dot gnu dot org
2004-10-14 18:08 ` [Bug c/17023] [3.3/3.4/4.0 " rth at gcc dot gnu dot org
2004-10-14 18:25 ` jsm at polyomino dot org dot uk
2004-10-14 19:55 ` rth at gcc dot gnu dot org
2004-10-14 20:05 ` jsm at polyomino dot org dot uk
2004-10-14 20:12 ` jsm at polyomino dot org dot uk
2004-10-14 21:09 ` rth at gcc dot gnu dot org
2004-10-14 23:13 ` cvs-commit at gcc dot gnu dot org
2004-10-14 23:21 ` cvs-commit at gcc dot gnu dot org
2004-10-14 23:25 ` rth at gcc dot gnu dot org

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).