Bug 16876 - [4.2 Regression] ICE on testcase with -O3 in fold-const
Summary: [4.2 Regression] ICE on testcase with -O3 in fold-const
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 20141 20680 24210 (view as bug list)
Depends on:
Blocks: 29478
  Show dependency treegraph
 
Reported: 2004-08-04 15:34 UTC by marcus
Modified: 2018-03-12 14:57 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3 3.0.4 4.2.0 4.3.0
Known to fail: 3.3.3 3.4.0 4.0.0 4.0.4 3.2.3
Last reconfirmed: 2005-11-20 20:28:58


Attachments
parse_opts.i (100 bytes, text/plain)
2004-08-04 15:34 UTC, marcus
Details
patch (689 bytes, patch)
2006-08-24 19:13 UTC, Jorn Wolfgang Rennecke
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description marcus 2004-08-04 15:34:17 UTC
On AMD64, PPC, PPC64, i386: 
 
gcc -O3 -c parse_opts.i 
parse_opts.i: In function `f': 
parse_opts.i:11: internal compiler error: in gen_lowpart, at emit-rtl.c:1436 
 
The code is invalid (a bit), but it should not crash. 
 
reproduced with mainline from some days ago, 3.3-hammer branch, 3.4 branch 
too.
Comment 1 marcus 2004-08-04 15:34:49 UTC
Created attachment 6881 [details]
parse_opts.i

compile with -O3 or -finline-functions
Comment 2 Andrew Pinski 2004-08-04 15:41:28 UTC
Confirmed, the code is undefined.  With the mainline we get a different ICE:
pr16876.c: In function `f':
pr16876.c:8: internal compiler error: in fold_convert, at fold-const.c:2000
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

But this is because of changes by me and other people.

Really this is a regression from 2.95.3 and 3.0.4 but that is because of the use of the RTL inliner with 
those versions instead of the tree inline.
Comment 3 Andrew Pinski 2004-11-02 15:52:48 UTC
: Search converges between 2001-11-11-trunk (#45) and 2001-11-18-trunk (#46).
Comment 4 Uroš Bizjak 2005-02-22 10:49:48 UTC
The problem in mainline is that 'tree type' of RECORD_TYPE enters fold_convert()
and triggers gcc_unreachable() in line 2003.

However Borland C++ exits with error: "Call to function 'g' with no prototype."
on line where g(0) is called.
Comment 5 Andrew Pinski 2005-02-22 13:45:38 UTC
*** Bug 20141 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2005-03-29 14:04:30 UTC
*** Bug 20680 has been marked as a duplicate of this bug. ***
Comment 7 Joseph S. Myers 2005-03-29 14:58:53 UTC
See also my notes <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00772.html> on
what should receive warnings (possibly compiled into aborts), what should
receive errors and how c_convert_parm_for_inlining (a) is too late for such
diagnostics and (b) fails actually to carry out the conversion or diagnostics
in certain cases.
Comment 8 Andrew Pinski 2005-10-05 11:59:57 UTC
*** Bug 24210 has been marked as a duplicate of this bug. ***
Comment 9 Mark Mitchell 2005-10-30 22:44:49 UTC
P2 is the right setting for this bug; it's popping up often enough to make it worth fixing.  Disabling the inlining in the case that the argument type doesn't match (closely enough) the parameter type seems reasonable to me, even without introducing a subsequent runtime abort.  That would be equivalent to the behavior if the function called appeared in a different translation unit.
Comment 10 Steven Bosscher 2005-12-18 17:15:16 UTC
rth assigned this to himself: http://gcc.gnu.org/ml/gcc-bugs/2005-11/msg02843.html

A progress report would be nice ;-)
Comment 11 Mark Mitchell 2006-02-24 00:25:10 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 12 Mark Mitchell 2006-05-25 02:31:50 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 13 Steven Bosscher 2006-06-05 10:41:30 UTC
Unassigning rth, since he's obviously not actually interested in fixing this.
Comment 14 Steven Bosscher 2006-06-05 10:44:08 UTC
The failures in 3.4 and later are in fold_const, so the gen_lowpart problem is now avoided by, well, ICEing earlier :)
Comment 15 Jorn Wolfgang Rennecke 2006-08-24 19:13:24 UTC
Created attachment 12130 [details]
patch

I think this should do the trick.
Comment 16 Jorn Wolfgang Rennecke 2006-08-25 18:52:07 UTC
Subject: Bug 16876

Author: amylaar
Date: Fri Aug 25 18:51:57 2006
New Revision: 116424

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116424
Log:
gcc:
	PR tree-optimization/16876
	* c-typeck.c (c_convert_parm_for_inlining): Don't take early
	exit if PARM doesn't match VALUE.

testsuite:
	gcc.dg/noncompile/pr16876.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/noncompile/pr16876.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 17 Richard Biener 2006-10-18 09:26:06 UTC
A backport of the patch bootstraps & regtests ok on the 4.1 branch, but I'm unsure we want the side-effects of the rejects-valid, because this is valid code according to jsm (only undefined at runtime).
Comment 18 Andrew Pinski 2006-10-18 18:56:39 UTC
(In reply to comment #17)
> A backport of the patch bootstraps & regtests ok on the 4.1 branch.
Except it introduces PR 29478.
Comment 19 Richard Biener 2007-06-23 18:18:10 UTC
Subject: Bug 16876

Author: rguenth
Date: Sat Jun 23 18:17:57 2007
New Revision: 125974

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125974
Log:
2007-06-23  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/16876
	PR middle-end/29478
	* tree.h (CALL_CANNOT_INLINE_P): New macro to access static_flag
	for CALL_EXPRs.
	* tree-inline.c (initialize_inlined_parameters): Do not call
	lang_hooks.tree_inlining.convert_parm_for_inlining.
	* cgraphbuild.c (initialize_inline_failed): Set inline failed
	reason for mismatched types.
	* gimplify.c (gimplify_call_expr): Verify the call expression
	arguments match the called function type signature.  Otherwise
	mark the call expression to be not considered for inlining
	using CALL_CANNOT_INLINE_P flag.
	* ipa-inline.c (cgraph_mark_inline): Honor CALL_CANNOT_INLINE_P on the
	edges call expression.
	(cgraph_decide_inlining_of_small_function): Likewise.
	(cgraph_decide_inlining): Likewise.
	* c-objc-common.h (LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING):
	Remove define.
	* c-tree.h (c_convert_parm_for_inlining): Remove declaration.
	* c-typeck.c (c_convert_parm_for_inlining): Remove.
	* langhooks-def.h (lhd_tree_inlining_convert_parm_for_inlining):
	Remove declaration.
	(LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING): Remove define.
	* langhooks.c (lhd_tree_inlining_convert_parm_for_inlining):
	Remove.
	* langhooks.h (struct lang_hooks_for_tree_inlining): Remove
	convert_parm_for_inlining member.

	* gcc.dg/pr29254.c: The warning is bogus.
	* gcc.dg/warn-1.c: Likewise.
	* gcc.dg/assign-warn-3.c: Likewise.
	* gcc.dg/noncompile/pr16876.c: The testcase is bogus, remove.

Removed:
    trunk/gcc/testsuite/gcc.dg/noncompile/pr16876.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-objc-common.h
    trunk/gcc/c-tree.h
    trunk/gcc/c-typeck.c
    trunk/gcc/cgraphbuild.c
    trunk/gcc/gimplify.c
    trunk/gcc/ipa-inline.c
    trunk/gcc/langhooks-def.h
    trunk/gcc/langhooks.c
    trunk/gcc/langhooks.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/assign-warn-3.c
    trunk/gcc/testsuite/gcc.dg/pr29254.c
    trunk/gcc/testsuite/gcc.dg/warn-1.c
    trunk/gcc/tree-inline.c
    trunk/gcc/tree.h

Comment 20 Volker Reichelt 2007-07-03 00:10:42 UTC
As the code is deemed valid, we still have a rejects-valid bug on the 4.2 branch.
Comment 21 Mark Mitchell 2007-10-09 19:20:56 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 22 Joseph S. Myers 2008-02-01 16:52:36 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 23 Joseph S. Myers 2008-05-19 20:22:31 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 24 Joseph S. Myers 2008-07-04 22:44:52 UTC
Closing 4.1 branch.
Comment 25 Joseph S. Myers 2009-03-30 15:37:16 UTC
Closing 4.2 branch.  Original bug was fixed for 4.2.0, rejects-valid
for 4.3.0.