public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/16567] New: Nested function and variable-sized structure ICE
@ 2004-07-15 14:55 jsm28 at gcc dot gnu dot org
  2004-07-15 15:10 ` [Bug middle-end/16567] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2004-07-15 14:55 UTC (permalink / raw)
  To: gcc-bugs

The following GNU C testcase ICEs with every compiler version tested
from 2.6.3 to recent mainline.  With mainline 3.5.0 20040710 on
i686-pc-linux-gnu, the error is:

t.c: In function `nested':
t.c:12: internal compiler error: in make_decl_rtl, at varasm.c:758
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

With 3.4.1, the error is:

t.c: In function `nested':
t.c:12: internal compiler error: in expand_expr_real, at expr.c:6638
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The proper fix may well involve getting rid of variable-sized structures
in GNU C, but I don't know whether the problem can be triggered with
equivalent testcases in other languages (all ICEs are in various middle-end
files).

#include <stddef.h>

extern int printf (const char *, ...);
extern void *memset (void *, int, size_t);

int bar (int (*)(), int, void *);

int
main(int argc, char **argv)
{
  struct s { int a; char b[argc]; };
  int nested (struct s x) { return x.a + sizeof(x); }
  struct s t;
  memset (&t, 0, sizeof(t));
  t.a = 123;
  printf("%d\n", bar (nested, argc, &t));
  return 0;
}

-- 
           Summary: Nested function and variable-sized structure ICE
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: middle-end
        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=16567


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
@ 2004-07-15 15:10 ` bangerth at dealii dot org
  2004-07-15 15:17 ` bangerth at dealii dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2004-07-15 15:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-07-15 15:10 -------
Confirmed indeed. I guess we should say "don't do evil things!" :-) 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-15 15:10:46
               date|                            |


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
  2004-07-15 15:10 ` [Bug middle-end/16567] " bangerth at dealii dot org
@ 2004-07-15 15:17 ` bangerth at dealii dot org
  2004-07-15 15:25 ` jsm at polyomino dot org dot uk
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2004-07-15 15:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-07-15 15:17 -------
BTW, the code is definitely invalid (even leaving aside the matter of 
variable-sized structures). You declare 
  int bar (int (*)(), int, void *); 
and call it with 
  int nested (struct s x) { return x.a + sizeof(x); } 
  bar (nested, argc, &t); 
Note that &nested does not satisfy the signature that bar() expects 
as first argument. It seems, however, as if we never even get to 
the point where gcc would like to check for this, it ICEs before that. 
 
Here's something that should be closer to validity: 
--------------- 
void bar (void *); 
 
int main(int argc, char **argv) { 
  struct s { char b[argc]; }; 
  int nested (struct s x) { return 0; } 
  struct s t; 
  bar ((void*)&nested); 
  return 0; 
} 
---------------- 
 
g/x> /home/bangerth/bin/gcc-3.5*/bin/gcc -c x.c 
x.c: In function `nested': 
x.c:5: internal compiler error: in make_decl_rtl, at varasm.c:758 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
g/x> /home/bangerth/bin/gcc-2.95.3/bin/gcc -c x.c 
x.c: In function `nested': 
x.c:5: Internal compiler error in `fix_lexical_addr', at function.c:5622 
Please submit a full bug report. 
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. 
 
W. 

-- 


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
  2004-07-15 15:10 ` [Bug middle-end/16567] " bangerth at dealii dot org
  2004-07-15 15:17 ` bangerth at dealii dot org
@ 2004-07-15 15:25 ` jsm at polyomino dot org dot uk
  2004-10-14  1:55 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-07-15 15:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-07-15 15:25 -------
Subject: Re:  Nested function and variable-sized
 structure ICE

On Thu, 15 Jul 2004, bangerth at dealii dot org wrote:

> BTW, the code is definitely invalid (even leaving aside the matter of 
> variable-sized structures). You declare 
>   int bar (int (*)(), int, void *); 
> and call it with 
>   int nested (struct s x) { return x.a + sizeof(x); } 
>   bar (nested, argc, &t); 
> Note that &nested does not satisfy the signature that bar() expects 
> as first argument. It seems, however, as if we never even get to 
> the point where gcc would like to check for this, it ICEs before that. 

I deliberately declare bar's first argument with an old-style
non-prototype declaration precisely because a matching prototype can't be
written at that point - but &nested can match a simple "pointer to
function returning int"!  (The original two-file testcase
<http://gcc.gnu.org/ml/gcc/2004-07/msg00776.html> was intended to be a
valid illustration of how variable-sized arguments are part of the C ABI,
which had the unintended effect of showing the ABI to be completely
irrelevant for this code because all versions of GCC ICE on it.)



-- 


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-07-15 15:25 ` jsm at polyomino dot org dot uk
@ 2004-10-14  1:55 ` pinskia at gcc dot gnu dot org
  2004-10-15 13:49 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-14  1:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-14 01:54 -------
This now works on the mainline.  If I get time I will apply the testcase (otherwise someone else can do 
that plus close the bug).

-- 


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-10-14  1:55 ` pinskia at gcc dot gnu dot org
@ 2004-10-15 13:49 ` pinskia at gcc dot gnu dot org
  2004-10-15 13:49 ` cvs-commit at gcc dot gnu dot org
  2004-10-15 13:51 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-15 13:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-15 13:49 -------
Fixed: Search converges between 2004-07-16-trunk (#487) and 2004-07-17-trunk (#488).
Committed the testcase so closing.

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


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-10-15 13:49 ` pinskia at gcc dot gnu dot org
@ 2004-10-15 13:49 ` cvs-commit at gcc dot gnu dot org
  2004-10-15 13:51 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-15 13:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-15 13:49 -------
Subject: Bug 16567

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2004-10-15 13:49:21

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: nested-1.c 

Log message:
	2004-10-14  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/16567
	* gcc.c-torture/compile/nested-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/nested-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4454&r2=1.4455



-- 


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


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

* [Bug middle-end/16567] Nested function and variable-sized structure ICE
  2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-10-15 13:49 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-15 13:51 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-15 13:51 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2004-10-15 13:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-15 14:55 [Bug middle-end/16567] New: Nested function and variable-sized structure ICE jsm28 at gcc dot gnu dot org
2004-07-15 15:10 ` [Bug middle-end/16567] " bangerth at dealii dot org
2004-07-15 15:17 ` bangerth at dealii dot org
2004-07-15 15:25 ` jsm at polyomino dot org dot uk
2004-10-14  1:55 ` pinskia at gcc dot gnu dot org
2004-10-15 13:49 ` pinskia at gcc dot gnu dot org
2004-10-15 13:49 ` cvs-commit at gcc dot gnu dot org
2004-10-15 13:51 ` pinskia 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).