Bug 24329 - [4.0 regression] segfault with -Wall and long integer literal
Summary: [4.0 regression] segfault with -Wall and long integer literal
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.2
: P1 normal
Target Milestone: 4.0.3
Assignee: Joseph S. Myers
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2005-10-12 09:49 UTC by Joachim Desoutter
Modified: 2005-11-03 15:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.5 4.1.0
Known to fail: 4.0.2
Last reconfirmed: 2005-11-03 00:50:36


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Desoutter 2005-10-12 09:49:35 UTC
gcc -Wall -o degre-radian degre-radian.c gives me an error when I try to compile my source code.

I'm using Debian GNU/Linux SID with a 2.4.27-2-386 linux kernel.
Steps to reproduce : 
1) Download my source code (at http://jojosan.hd.free.fr/jojosan/degre-radian.c)
2) Try to compile it.

I suppose that it's the 100-decimal precision of pi that I defined that causes the crash, but I really need for further uses to get it that precise and... it's a bug, after all !

The
gcc -Wall -o degre-radian degre-radian.c gives me that error :
----------------------
degre-radian.c: In function 'main':
degre-radian.c:15: warning: comparison between pointer and integer
degre-radian.c:17:23: warning: integer constant is too large for its type
degre-radian.c:17: warning: integer constant is too large for 'long' type
degre-radian.c:17: warning: left-hand operand of comma expression has no effect
degre-radian.c:20: warning: comparison between pointer and integer
degre-radian.c:22:40: warning: integer constant is too large for its type
degre-radian.c:22: warning: integer constant is too large for 'long' type
degre-radian.c:23:94: warning: integer constant is too large for its type
degre-radian.c:23: warning: integer constant is too large for 'long' type
degre-radian.c:23: warning: left-hand operand of comma expression has no effect
gcc: Internal error: Erreur de segmentation (program cc1)
Please submit a full bug report.
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.0/README.Bugs>.
----------------------

Apparently, there is no terrible error in the source code, (no "error" message), so I suppose that it's GCC's (seg)fault. GCC should then be able to generate my binary.

gcc --version gives me these informations : 

gcc (GCC) 4.0.2 (Debian 4.0.2-1)
Comment 1 Falk Hueffner 2005-10-12 10:06:38 UTC
Confirmed. Test case:

int printf(const char *format, ...);
int f() {
  printf("%d", 141592653589793238462643383279502884197169399375105820974944);
}
Comment 2 Andrew Pinski 2005-10-12 11:34:14 UTC
We have an infinite loop in pp_c_type_specifier.
Comment 3 Andrew Pinski 2005-10-12 13:05:41 UTC
hmm, for some reason this works on i686-pc-linux-gnu but not on powerpc-darwin.
Comment 4 Mark Mitchell 2005-10-31 06:13:37 UTC
We need to analyze this.  Unless this is a Darwin libc bug, this is a showstopper. 
Comment 5 Janis Johnson 2005-11-01 23:34:32 UTC
GCC 3.3.5 for powerpc-linux compiles with appropriate warnings.
GCC 3.4.* for powerpc64-linux compiles as expected for -m64 but ICEs in
extract_insn, at recog.c:2083 for -m32
GCC 4.0.* for powerpc64-linux segfaults for both -m32 and -m64, as does mainline.
Comment 6 Joseph S. Myers 2005-11-03 00:50:36 UTC
Testing a patch.
Comment 7 Joseph S. Myers 2005-11-03 03:30:42 UTC
Subject: Bug 24329

Author: jsm28
Date: Thu Nov  3 03:30:36 2005
New Revision: 106421

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106421
Log:
	PR c/24329
	* c-pretty-print.c (pp_c_type_specifier): Do not recurse if
	c_common_type_for_mode returns an unnamed type.

testsuite:
	* gcc.dg/format/unnamed-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/format/unnamed-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-pretty-print.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Andrew Pinski 2005-11-03 14:44:56 UTC
Fixed at least on the mainline.
Comment 9 Joseph S. Myers 2005-11-03 14:49:27 UTC
Subject: Bug 24329

Author: jsm28
Date: Thu Nov  3 14:49:23 2005
New Revision: 106433

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106433
Log:
	PR c/24329
	* c-pretty-print.c (pp_c_type_specifier): Do not recurse if
	c_common_type_for_mode returns an unnamed type.

testsuite:
	* gcc.dg/format/unnamed-1.c: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/format/unnamed-1.c
      - copied unchanged from r106421, trunk/gcc/testsuite/gcc.dg/format/unnamed-1.c
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/c-pretty-print.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 10 Andrew Pinski 2005-11-03 15:21:24 UTC
Fixed.