Bug 28677 - [4.0 regression] Function prototype in function body crashes compilation
Summary: [4.0 regression] Function prototype in function body crashes compilation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on: 16792 26757
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-10 12:19 UTC by Werner Van Belle
Modified: 2007-02-03 18:45 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6 4.2.0 4.1.2
Known to fail: 4.0.4 4.1.1
Last reconfirmed: 2006-08-10 19:42:05


Attachments
The preprocessed source (11.51 KB, text/plain)
2006-08-10 12:20 UTC, Werner Van Belle
Details
gcc41-pr27793.patch (3.73 KB, patch)
2006-08-12 19:45 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Werner Van Belle 2006-08-10 12:19:47 UTC
werner@dig:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060729 (prerelease) (Debian 4.1.1-10)

I currently use the latest Debian unstable system.

werner@dig~$ g++ -O3 -g crasher.cpp
crasher.cpp: In function 'float betai(float, float, float)':
crasher.cpp:43: internal compiler error: in add_AT_specification, at dwarf2out.c:5048
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
Preprocessed source stored into /tmp/ccH8vLQj.out file, please attach this to your bugreport.

the preprocessed source will be attached.
Comment 1 Werner Van Belle 2006-08-10 12:20:19 UTC
Created attachment 12057 [details]
The preprocessed source
Comment 2 Werner Van Belle 2006-08-10 12:25:38 UTC
The bug does not occur without the -g option.
Comment 3 Martin Michlmayr 2006-08-10 19:42:05 UTC
Fails with 4.0 and 4.1, works with 3.4 and 4.2.
Comment 4 Martin Michlmayr 2006-08-10 19:49:24 UTC
{
  __inline double fabs (double __x) throw ()
  {
  }
  typedef struct
  {
  }
   *__locale_t;
  extern void exit (int __status) throw () __attribute__ ((__noreturn__));
}
void
nrerror (char error_text[])
{
  exit (1);
}
float
betacf (float a, float b, float x)
{
  void nrerror (char error_text[]);
  float aa, c, d, del, h, qab, qam, qap;
  d = 1.0 - qab * x / qap;
  if (fabs (d) < 1.0e-30)
  h = d;
    {
      if (fabs (d) < 1.0e-30)
        d = 1.0e-30;
    }
  return h;
}
float
betai (float a, float b, float x)
{
  void nrerror (char error_text[]);
    nrerror ("Bad x in routine betai");
}
Comment 5 Martin Michlmayr 2006-08-10 20:18:37 UTC
Further reduced:

double fabs (double __x) { }
extern void exit (int __status);
void
nrerror (void)
{
  exit(0);
}
float
betacf (float x)
{
  void nrerror (void);
  float d, h;
  d = 1.0 - x;
  if (fabs (d) < 1.0e-30)
    h = d;
  return h;
}
void
betai (void)
{
  void nrerror (void);
  nrerror ();
}
Comment 6 Andrew Pinski 2006-08-10 20:19:12 UTC
I bet this was fixed by the patch which fixed PR 26757 finnally (comment #28).
Comment 7 Martin Michlmayr 2006-08-10 20:44:10 UTC
(In reply to comment #6)
> I bet this was fixed by the patch which fixed PR 26757 finnally (comment #28).

I can confirm this.
Comment 8 Martin Michlmayr 2006-08-10 20:51:18 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > I bet this was fixed by the patch which fixed PR 26757 finnally (comment #28).
> 
> I can confirm this.

Jakub, can you apply your patch for PR 26757 to 4.0 and 4.1?
Comment 9 Janis Johnson 2006-08-10 23:15:25 UTC
In case Jakub's patch can't be backported easily, this might be useful.  A regression hunt on powerpc-linux identified the following patch as the start of failures for the testcase in comment #5:

    http://gcc.gnu.org/viewcvs?view=rev&rev=83405

    r83405 | zack | 2004-06-20 08:34:54 +0000 (Sun, 20 Jun 2004)
Comment 10 Andrew Pinski 2006-08-10 23:25:59 UTC
(In reply to comment #9) 
>     http://gcc.gnu.org/viewcvs?view=rev&rev=83405

Not really, it was this part that caused it:
	* name-lookup.c (pushdecl): When a local extern shadows a
	file-scope declaration of the same object, give both DECLs the
	same DECL_UID.

Which I was semi expecting.
And this is related to PR 16792.
Comment 11 Jakub Jelinek 2006-08-12 19:45:19 UTC
Created attachment 12071 [details]
gcc41-pr27793.patch

It certainly can be backported easily, I'm using this patch on top of redhat/gcc-4_1-branch for 2 months already, in the mean time recompiled
the whole distribution with it etc.
Not sure about 4.0 branch though.
I'll bootstrap/regression test this on vanilla gcc-4_1-branch and post for approval.
Comment 12 Jakub Jelinek 2006-08-13 19:26:52 UTC
Subject: Bug 28677

Author: jakub
Date: Sun Aug 13 20:26:38 2006
New Revision: 116115

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116115
Log:
2006-08-13  Andrew MacLeod  <amacleod@redhat.com>

	PR middle-end/27793
	* tree-dfa.c (add_referenced_var): Assert DECL_UID is unique for
	different decls.

2006-08-13  Jakub Jelinek  <jakub@redhat.com>

	PR c++/28677
	PR middle-end/27793
	* cp-tree.h (cxx_int_tree_map): New struct.
	(struct language_function): Add extern_decl_map field.
	* name-lookup.c (pushdecl_maybe_friend): Add x -> t mapping
	to cp_function_chain->extern_decl_map hash table instead of
	copying over DECL_UID.
	* cp-gimplify.c (cxx_int_tree_map_eq, cxx_int_tree_map_hash): New
	functions.
	(cp_genericize_r): Remap DECL_EXTERN local decls using
	cp_function_chain->extern_decl_map hash table.
	* decl.c (finish_function): Clear extern_decl_map.

	Revert:
	2006-06-06  Andrew MacLeod  <amacleod@redhat.com>
	PR middle-end/27793
	* tree-dfa.c (referenced_vars_dup_list): New.  List of duplicate 
	referenced_variables with matching DECL_UID's.
	(find_referenced_vars): Make sure duplicate list is empty to start.
	(add_referenced_var): Add var to duplicate list if required.
	* tree-ssa.c (delete_tree_ssa): Clear var_ann's on duplicates.
	* tree-flow.h (referenced_vars_dup_list): External declaration.

	PR c++/26757
	PR c++/27894
	* g++.dg/tree-ssa/pr26757.C: New test.
	* g++.dg/tree-ssa/pr27894.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/tree-ssa/pr26757.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/tree-ssa/pr27894.C
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/cp-gimplify.c
    branches/gcc-4_1-branch/gcc/cp/cp-tree.h
    branches/gcc-4_1-branch/gcc/cp/decl.c
    branches/gcc-4_1-branch/gcc/cp/name-lookup.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-dfa.c
    branches/gcc-4_1-branch/gcc/tree-flow.h
    branches/gcc-4_1-branch/gcc/tree-ssa.c

Comment 13 Andrew Pinski 2006-08-16 05:37:55 UTC
Fixed in 4.0.4.
Comment 14 Andrew Pinski 2006-08-16 05:38:14 UTC
(In reply to comment #13)
> Fixed in 4.0.4.
I mean 4.1.2.
Comment 15 Gabriel Dos Reis 2007-02-03 18:45:00 UTC
Fixed in GCC-4.1.2.