Bug 98728 - gcc internal compiler error encountered
Summary: gcc internal compiler error encountered
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
(Show other bugs)
Version: 8.0
Hardware: All Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2003-07-08 01:06 UTC by Mike Rubel
Modified: 2011-11-22 07:34 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-07-08 09:05:21 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Mike Rubel 2003-07-08 01:06:25 UTC
Description of problem:

Encountered "Internal compiler error," following instruction to submit to bugzilla.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Save the file compiler_error.c (about 30 lines), given below.
2. Compile it with gcc -Wall -o compiler_error compiler_error.c ; works
3. Compile it with gcc -Wall -O3 -o compiler_error compiler_error.c ;
   generates internal compiler error message.
Actual results:

$ gcc -Wall -O3 -o compiler_error compiler_error.c
compiler_error.c: In function `main':
compiler_error.c:17: Internal compiler error in find_function_data, at
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Expected results:

Normal compilation.

Additional info:

Here is a test code which demonstrates the problem.  Contorted example, I know,
but should be legal in gcc.

--------------->8 compiler_error.c 8<-----------------
#include <stdio.h>
static void *fcn;
static int arg_length;
static char buf[2048];

void simple_test_function(int a, int b)
  printf("a: %d, b:%d\n", a, b);

void RunFunction(void)
  struct arglen_buf_s { char buf[arg_length]; };
  void (*f)() = (void *) fcn;
  (void) f( *(struct arglen_buf_s *) buf );

int main(void)
  int *args_ptr;
  fcn = (void *) simple_test_function;

  arg_length = 2 * sizeof(int);
  args_ptr = (void *) buf;
  args_ptr[0] = 5;
  args_ptr[1] = 7;


  return 0;

Comment 1 Jakub Jelinek 2003-07-08 09:05:21 UTC
This is certainly not legal ISO C.
You cannot call a function with a different arguments than it accepts.
And even without inlining this will not work on most architectures
(very likely will not work on any 64-bit architecture, on any architecture
which passes structures by reference or where integers are passed in different
location than variable length aggregates).
It is true that gcc should not ICE on any input, just issue diagnostics,
but I really have no interest in fixing this exact case. File a PR on gcc.gnu.org
if you want the ICE to be fixed.
If you want to keep this ugly hack and don't care it is basically IA-32 only hack,
you either need to add __attribute__((noinline)) somewhere or force gcc to forget
what fn points to (say with asm ("" : "=r" (f) : "0" (f));).

Comment 2 Jakub Jelinek 2003-07-08 09:07:23 UTC
Oh, and have a look at libffi (included in GCC sources), this is a library
which does what you are trying to do, in both directions and for lots of

Note You need to log in before you can comment on or make changes to this bug.