Bug 25364 - [4.0/4.1/4.2 Regression] ICE with function pointer as template parameter
Summary: [4.0/4.1/4.2 Regression] ICE with function pointer as template parameter
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P1 critical
Target Milestone: 4.0.3
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
: 25383 25659 (view as bug list)
Depends on:
Blocks: 22149
  Show dependency treegraph
 
Reported: 2005-12-12 10:11 UTC by Phil Barrett
Modified: 2006-01-09 15:58 UTC (History)
7 users (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work: 4.0.0 4.0.2
Known to fail: 4.0.3
Last reconfirmed: 2005-12-12 18:39:55


Attachments
Preprocessed file that causes error (135.60 KB, application/octet-stream)
2005-12-12 10:13 UTC, Phil Barrett
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Barrett 2005-12-12 10:11:31 UTC
internal compiler error: in build_call, at cp/call.c:323

Can't narrow it down - happens in five different places in our codebase.
Comment 1 Phil Barrett 2005-12-12 10:13:25 UTC
Created attachment 10455 [details]
Preprocessed file that causes error
Comment 2 Phil Barrett 2005-12-12 12:26:14 UTC
Just tested; it's live in 4.0-20051208.
Comment 3 Andrew Pinski 2005-12-12 15:16:57 UTC
Reducing.
Comment 4 Andrew Pinski 2005-12-12 18:39:55 UTC
Reduced to:
class OFX_PropertySuiteV1
{
    static int propGetDouble ();
};
template<int dimension,
  class T,
  int (*PROPGET)()
  >
struct OFX_AnimatedNumberParam
{
    virtual int paramSetValueAtTime()
    {
     return PROPGET();
    }
};
void  f()
{
new OFX_AnimatedNumberParam<2,double,OFX_PropertySuiteV1::propGetDouble>();
}
Comment 5 Volker Reichelt 2005-12-12 23:46:08 UTC
This is a regression from 4.0.2.
Comment 6 Volker Reichelt 2005-12-13 01:59:59 UTC
Mark, this appeared with your patch
http://gcc.gnu.org/ml/gcc-cvs/2005-10/msg00056.html

Looks like a latent bug, though.

BTW, the code compiles with a function reference instead of a function pointer as template parameter.
Comment 7 Andrew Pinski 2005-12-13 08:06:53 UTC
*** Bug 25383 has been marked as a duplicate of this bug. ***
Comment 8 Phil Barrett 2005-12-13 14:41:03 UTC
Disagree with known to work 4.0.2 - original report was from 4.0.2.
Comment 9 Mark Mitchell 2005-12-19 19:30:53 UTC
Must be fixed: P1.
Comment 10 Volker Reichelt 2005-12-22 08:38:21 UTC
Shorter testcase:

=====================================
struct A
{
    static void foo();
};

template<void (*fp)()> struct B
{
    B() { fp(); }
};

B<A::foo> b;
=====================================
Comment 11 Mark Mitchell 2005-12-22 19:59:03 UTC
Subject: Bug 25364

Author: mmitchel
Date: Thu Dec 22 19:59:00 2005
New Revision: 108971

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108971
Log:
	PR c++/25364
	* semantics.c (finish_qualified_id_expr): Call mark_used.

	PR c++/25364
	* g++.dg/template/call4.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/call4.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/semantics.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 12 Mark Mitchell 2005-12-22 20:02:28 UTC
Subject: Bug 25364

Author: mmitchel
Date: Thu Dec 22 20:02:21 2005
New Revision: 108972

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108972
Log:
	PR c++/25364
	* semantics.c (finish_qualified_id_expr): Call mark_used.
	(finish_id_expression): Likewise.

	PR c++/25364
	* g++.dg/template/call4.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/call4.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/semantics.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 13 Mark Mitchell 2005-12-22 20:08:43 UTC
Subject: Bug 25364

Author: mmitchel
Date: Thu Dec 22 20:08:39 2005
New Revision: 108973

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108973
Log:
	PR c++/25364
	* typeck.c (build_unary_op): Pass DECLs not names to
	build_offset_refs.
	* init.c (build_offset_ref): Do not do name lookup.  Do not call
	mark_used.
	* call.c (build_call): Simplify and tidy.
	* semantics.c (finish_qualified_id_expr): Call mark_used.
	PR c++/25364
	* g++.dg/template/call4.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/call4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 14 Mark Mitchell 2005-12-22 20:15:47 UTC
Fixed in 4.0.3.
Comment 15 Andrew Pinski 2006-01-04 03:42:45 UTC
*** Bug 25659 has been marked as a duplicate of this bug. ***
Comment 16 Andrew Pinski 2006-01-04 03:44:40 UTC
(In reply to comment #8)
> Disagree with known to work 4.0.2 - original report was from 4.0.2.

I actually disagree with saying the compiler you are using is a 4.0.2 compiler.  It is a 4.0.3 compiler from the date you gave in comment #3.
Comment 17 Phil Barrett 2006-01-04 09:17:30 UTC
It's live in the 4.0.2 installed by a Fedora Core 4 yum update right now (4.0.2 20051125 (Red Hat 4.0.2-8)).
Comment 18 Volker Reichelt 2006-01-04 11:43:27 UTC
> It's live in the 4.0.2 installed by a Fedora Core 4 yum update right now
> (4.0.2 20051125 (Red Hat 4.0.2-8)).

This is not the official FSF 4.0.2 release.
Redhat's 4.0.2-8 version contains some patches from the 4.0.3 release.
Even their gcc.info file says so:

  This manual documents how to use the GNU compilers, as well as their
  features and incompatibilities, and how to report bugs.  It corresponds
  to GCC version 4.0.3.  The internals of the GNU compilers, including
                ^^^^^^^
Comment 19 Phil Barrett 2006-01-09 15:58:21 UTC
Verified fixed (against original source problem) in 4.0.3 20060105