[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-04 Thread rakdver at gcc dot gnu dot org


--- Comment #12 from rakdver at gcc dot gnu dot org  2006-01-04 22:46 
---
Subject: Bug 25632

Author: rakdver
Date: Wed Jan  4 22:46:09 2006
New Revision: 109354

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=109354
Log:
PR c++/25632
* init.c (constant_value_1): Unshare use of DECL_INITIAL.  Fix a typo
in condition.


Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/init.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-04 Thread rakdver at gcc dot gnu dot org


--- Comment #13 from rakdver at gcc dot gnu dot org  2006-01-05 00:29 
---
Subject: Bug 25632

Author: rakdver
Date: Thu Jan  5 00:29:34 2006
New Revision: 109369

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=109369
Log:
PR c++/25632
* init.c (constant_value_1): Unshare use of DECL_INITIAL.  Fix a typo
in condition.


Modified:
branches/gcc-4_1-branch/gcc/cp/ChangeLog
branches/gcc-4_1-branch/gcc/cp/init.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread rakdver at gcc dot gnu dot org


--- Comment #4 from rakdver at gcc dot gnu dot org  2006-01-03 11:31 ---
Adding unshare_expr to constant_value_1 fixes the problem, but causes bootstrap
failure.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread pinskia at gcc dot gnu dot org


--- Comment #5 from pinskia at gcc dot gnu dot org  2006-01-03 14:12 ---
Caused by either:
2005-10-16  Mark Mitchell  [EMAIL PROTECTED]

PR c++/24389
* decl2.c (mark_used): Use uses_template_parms instead of
dependent_type_p.
* init.c (constant_value_1): Handle uninstantiated templates
specially. 
* pt.c (instantiate_decl): Add sanity check.
or
2005-10-11  Mark Mitchell  [EMAIL PROTECTED]

PR c++/21089
* call.c (convert_like_real): Use decl_constant_value, not
integral_constant_value.
* init.c (constant_value_1): New function.
(integral_constant_value): Use it.
(decl_constant_value): Likewise.
* typeck.c (decay_conversion): Use decl_constant_value, not
integral_constant_value.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread rakdver at gcc dot gnu dot org


--- Comment #6 from rakdver at gcc dot gnu dot org  2006-01-03 22:40 ---
Patch:

http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00136.html


-- 

rakdver at gcc dot gnu dot org changed:

   What|Removed |Added

URL||http://gcc.gnu.org/ml/gcc-
   ||patches/2006-
   ||01/msg00136.html
   Keywords||patch


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread mark at codesourcery dot com


--- Comment #7 from mark at codesourcery dot com  2006-01-03 23:01 ---
Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied
 into two different functions

rakdver at gcc dot gnu dot org wrote:
 --- Comment #6 from rakdver at gcc dot gnu dot org  2006-01-03 22:40 
 ---
 Patch:
 
 http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00136.html

This patch is not OK, but it's close.

We should not call unshare_expr on DECL_INITIAL until after the
mark_used call, as static data members in templates will not have proper
initializers until after that point.  Also, there's no need to unshare
*before* calling fold_non_dependent_expr.

In fact, there's no need to unshare before the return statement at the
end of the function.  That will avoid creating trees that will only be
thrown away later.

So, why not just do:

return unshare_expr (decl);

at the end of the function?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread rakdver at atrey dot karlin dot mff dot cuni dot cz


--- Comment #8 from rakdver at atrey dot karlin dot mff dot cuni dot cz  
2006-01-03 23:24 ---
Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied into two
different functions

 --- Comment #7 from mark at codesourcery dot com  2006-01-03 23:01 ---
 Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied
  into two different functions
 
 rakdver at gcc dot gnu dot org wrote:
  --- Comment #6 from rakdver at gcc dot gnu dot org  2006-01-03 22:40 
  ---
  Patch:
  
  http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00136.html
 
 This patch is not OK, but it's close.
 
 We should not call unshare_expr on DECL_INITIAL until after the
 mark_used call, as static data members in templates will not have proper
 initializers until after that point.  Also, there's no need to unshare
 *before* calling fold_non_dependent_expr.
 
 In fact, there's no need to unshare before the return statement at the
 end of the function.  That will avoid creating trees that will only be
 thrown away later.
 
 So, why not just do:
 
 return unshare_expr (decl);
 
 at the end of the function?

because that causes bootstrap failure --
fold_decl_constant_value does

   tree const_expr = expr;
   do
 {
   expr = fold_non_dependent_expr (const_expr);
   const_expr = integral_constant_value (expr);
 }
   while (expr != const_expr);

and if constant_value_1 (called by integral_constant_value) unshares the
expression unconditionally (not only when it processes DECL_INITIAL),
this loop never ends.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread rakdver at atrey dot karlin dot mff dot cuni dot cz


--- Comment #9 from rakdver at atrey dot karlin dot mff dot cuni dot cz  
2006-01-03 23:29 ---
Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied into two
different functions

 rakdver at gcc dot gnu dot org wrote:
  --- Comment #6 from rakdver at gcc dot gnu dot org  2006-01-03 22:40 
  ---
  Patch:
  
  http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00136.html
 
 This patch is not OK, but it's close.
 
 We should not call unshare_expr on DECL_INITIAL until after the
 mark_used call, as static data members in templates will not have proper
 initializers until after that point.  Also, there's no need to unshare
 *before* calling fold_non_dependent_expr.
 
 In fact, there's no need to unshare before the return statement at the
 end of the function.  That will avoid creating trees that will only be
 thrown away later.

what about this patch, then (assuming it passes testing)?

Index: cp/init.c
===
*** cp/init.c   (revision 109271)
--- cp/init.c   (working copy)
*** constant_value_1 (tree decl, bool integr
*** 1503,1508 
--- 1503,1510 
  mark_used (decl);
  init = DECL_INITIAL (decl);
}
+   init = unshare_expr (init);
+ 
if (!(init || init == error_mark_node)
  || !TREE_TYPE (init)
  || (integral_p


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread mark at codesourcery dot com


--- Comment #10 from mark at codesourcery dot com  2006-01-04 00:01 ---
Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied
 into two different functions

rakdver at atrey dot karlin dot mff dot cuni dot cz wrote:

tree const_expr = expr;
do
  {
expr = fold_non_dependent_expr (const_expr);
const_expr = integral_constant_value (expr);
  }
while (expr != const_expr);
 
 and if constant_value_1 (called by integral_constant_value) unshares the
 expression unconditionally (not only when it processes DECL_INITIAL),
 this loop never ends.

OK; then call unshare_expr after the break statement in
constant_value_1, and before decl = init;.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-03 Thread mark at codesourcery dot com


--- Comment #11 from mark at codesourcery dot com  2006-01-04 00:02 ---
Subject: Re:  [4.0/4.1/4.2 Regression] ICE with const int copied
 into two different functions

rakdver at atrey dot karlin dot mff dot cuni dot cz wrote:

 what about this patch, then (assuming it passes testing)?

Better -- but there's no reason to do it before the break statement; if
we're not going to use init, then we don't neeed to unshare it.  I think
you can do it right *after* the break statement.

 Index: cp/init.c
 ===
 *** cp/init.c   (revision 109271)
 --- cp/init.c   (working copy)
 *** constant_value_1 (tree decl, bool integr
 *** 1503,1508 
 --- 1503,1510 
   mark_used (decl);
   init = DECL_INITIAL (decl);
 }
 +   init = unshare_expr (init);
 + 
 if (!(init || init == error_mark_node)
   || !TREE_TYPE (init)
   || (integral_p
 
 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-02 Thread mmitchel at gcc dot gnu dot org


--- Comment #3 from mmitchel at gcc dot gnu dot org  2006-01-03 00:24 
---
ICE on valid, plausible code.


-- 

mmitchel at gcc dot gnu dot org changed:

   What|Removed |Added

   Priority|P3  |P1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632




[Bug c++/25632] [4.0/4.1/4.2 Regression] ICE with const int copied into two different functions

2006-01-02 Thread rakdver at gcc dot gnu dot org


-- 

rakdver at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |rakdver at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25632