Bug 23357 - [4.1 Regression] ICE with __alignof__ on template arguments
Summary: [4.1 Regression] ICE with __alignof__ on template arguments
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 critical
Target Milestone: 4.1.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code, monitored
: 23481 (view as bug list)
Depends on:
Blocks: 27465
  Show dependency treegraph
 
Reported: 2005-08-12 17:31 UTC by Andrew Pinski
Modified: 2006-05-07 03:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-14 18:12:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-08-12 17:31:10 UTC
Testcase:
template<typename _Tp>
struct __per_type_pool_policy
{
  static void _S_get_pool()
  {
    const static int __align = (__alignof__(_Tp) >= 1 ? __alignof__(_Tp) : 1);
    static int _S_tune( 2 >= __align ? 1 : __align);
  }
};

This did not ICE in 4.0.0.  Also this is reduced from PR 23352 but I was trying to reduce a different ICE 
when finding with this one.
Comment 1 Volker Reichelt 2005-08-19 14:34:04 UTC
*** Bug 23481 has been marked as a duplicate of this bug. ***
Comment 2 Volker Reichelt 2005-08-19 14:35:26 UTC
Confirmed. Similar testcase from PR 23481:

=========================================================
template<typename T> bool foo()
{
    const long int i = sizeof(T) > 1 ? sizeof(T) : 0;
    return i > 0;
}
=========================================================
Comment 3 Andrew Pinski 2005-09-04 14:54:01 UTC
It worked with "4.1.0 20050622".
Comment 4 Janis Johnson 2005-09-09 17:01:50 UTC
The testcase starts failing with this patch from pinskia:

  http://gcc.gnu.org/ml/gcc-cvs/2005-08/msg00068.html
Comment 5 Andrew Pinski 2005-09-09 17:11:41 UTC
This is more of the issue for a front-end person, mainly why are we calling convert_to_integer while in a 
template since that assumes all the types are set up correctly.
Comment 6 GCC Commits 2005-09-16 06:51:07 UTC
Subject: Bug 23357

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jason@gcc.gnu.org	2005-09-16 06:50:57

Modified files:
	gcc/cp         : ChangeLog cp-tree.def 
Added files:
	gcc/testsuite/g++.dg/template: sizeof10.C 

Log message:
	PR c++/23357
	* cp-tree.def (SIZEOF_EXPR, ALIGNOF_EXPR): Change code class to
	tcc_expression.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4894&r2=1.4895
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.109&r2=1.110
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/sizeof10.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Andrew Pinski 2005-09-16 15:42:12 UTC
Fixed.