public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++: fix ICE with CONST_DECLs
@ 2013-06-11 16:27 Mike Stump
  2013-06-11 16:39 ` Paolo Carlini
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Stump @ 2013-06-11 16:27 UTC (permalink / raw)
  To: gcc-patches patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 110 bytes --]

Here is a simple one.  When processing CONST_DECLs after an error, we can ICE.  This avoid the ICE.

Ok?


[-- Attachment #2: var.diff.txt --]
[-- Type: text/plain, Size: 735 bytes --]

2013-06-11  Mike Stump  <mikestump@comcast.net>

	* init.c (constant_value_1): Protect CONST_DECLs better in the
          face of errors.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 44e558e..133a162 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1988,7 +1988,7 @@ constant_value_1 (tree decl, bool integral_p, bool return_aggregate_cst_ok_p)
       init = DECL_INITIAL (decl);
       if (init == error_mark_node)
 	{
-	  if (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
+	  if (VAR_P (decl) && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
 	    /* Treat the error as a constant to avoid cascading errors on
 	       excessively recursive template instantiation (c++/9335).  */
 	    return init;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C++: fix ICE with CONST_DECLs
  2013-06-11 16:27 C++: fix ICE with CONST_DECLs Mike Stump
@ 2013-06-11 16:39 ` Paolo Carlini
  2013-06-11 18:00   ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2013-06-11 16:39 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches patches, Jason Merrill

On 06/11/2013 06:27 PM, Mike Stump wrote:
> Here is a simple one.  When processing CONST_DECLs after an error, we can ICE.  This avoid the ICE.
No testcase?

Paolo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C++: fix ICE with CONST_DECLs
  2013-06-11 16:39 ` Paolo Carlini
@ 2013-06-11 18:00   ` Jason Merrill
  2013-06-13  0:26     ` Mike Stump
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2013-06-11 18:00 UTC (permalink / raw)
  To: Paolo Carlini, Mike Stump; +Cc: gcc-patches patches

On 06/11/2013 12:39 PM, Paolo Carlini wrote:
> On 06/11/2013 06:27 PM, Mike Stump wrote:
>> Here is a simple one.  When processing CONST_DECLs after an error, we
>> can ICE.  This avoid the ICE.

> No testcase?

Yep; the patch is fine, but needs a testcase.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C++: fix ICE with CONST_DECLs
  2013-06-11 18:00   ` Jason Merrill
@ 2013-06-13  0:26     ` Mike Stump
  2013-06-13  0:36       ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Stump @ 2013-06-13  0:26 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Paolo Carlini, Mike Stump, gcc-patches patches

On Jun 11, 2013, at 11:00 AM, Jason Merrill <jason@redhat.com> wrote:
> On 06/11/2013 12:39 PM, Paolo Carlini wrote:
>> On 06/11/2013 06:27 PM, Mike Stump wrote:
>>> Here is a simple one.  When processing CONST_DECLs after an error, we
>>> can ICE.  This avoid the ICE.
> 
>> No testcase?
> 
> Yep; the patch is fine, but needs a test case.

I don't have a test case, it was found via code where overflow was incorrectly set while compiling libstdc++, that test case won't work in the trunk, as the trunk sets overflow correctly…

I've tried all sorts of test cases to try and get it to fail, and net result it won't.  There are a few major paths into the code and most will transform to NULL_TREE or 0.  The test case was something like the below, though this version can't be made to show an error that I've found.  I don't see how to get it to fail.

I've fixed our code to compute overflow correctly and the crash is of course gone.  So, it is possible that it is impossible to get the code to fail.

So, I think I want to withdraw the patch, no need to mess up the code, for cases that can't happen.  If it does happen, someone will validly hit it and we can fix it at that time.  Thoughts?


namespace std
{
  // 22.2.2  The numeric category.
  class __num_base
  {
  public:
    // NB: Code depends on the order of _S_atoms_out elements.
    // Below are the indices into _S_atoms_out.
    enum
      {
	_S_ominus,
	_S_oplus,
	_S_ox,
	_S_oX,
	_S_odigits,
	_S_odigits_end = _S_odigits + 16,
	_S_oudigits = _S_odigits_end,
	_S_oudigits_end = _S_oudigits + 16,
	_S_oe = _S_odigits + 14,  // For scientific notation, 'e'
	_S_oE = _S_oudigits + 14, // For scientific notation, 'E'
	_S_oend = _S_oudigits_end
      };

  };
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C++: fix ICE with CONST_DECLs
  2013-06-13  0:26     ` Mike Stump
@ 2013-06-13  0:36       ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2013-06-13  0:36 UTC (permalink / raw)
  To: Mike Stump; +Cc: Paolo Carlini, gcc-patches patches

Go ahead and apply the patch; it never hurts to make the code more robust.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-13  0:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-11 16:27 C++: fix ICE with CONST_DECLs Mike Stump
2013-06-11 16:39 ` Paolo Carlini
2013-06-11 18:00   ` Jason Merrill
2013-06-13  0:26     ` Mike Stump
2013-06-13  0:36       ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).