public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault
@ 2014-11-28 10:57 ville.voutilainen at gmail dot com
  2014-12-03  9:49 ` [Bug c++/64100] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-11-28 10:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

            Bug ID: 64100
           Summary: A static assert using the the current class in a
                    noexcept test leads to a segfault
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

template<typename> struct foo 
{ 
    static_assert(noexcept(((foo *)1)->~foo()), ""); 
}; 

template class foo<int>;

Clang diagnoses the use of the constructor of foo as an attempt to
use an incomplete type, gcc segfaults. See
http://melpon.org/wandbox/permlink/Xz0rchej4eij4tOA
for the actual trace.

This looks like a regression, since my build from 20141121 just silently
eats the code. 20141127 produces the segfault.


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
@ 2014-12-03  9:49 ` mpolacek at gcc dot gnu.org
  2014-12-03 10:38 ` ktietz at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-12-03  9:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-03
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |4.8.4
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I see ICE even with 4.6.


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
  2014-12-03  9:49 ` [Bug c++/64100] " mpolacek at gcc dot gnu.org
@ 2014-12-03 10:38 ` ktietz at gcc dot gnu.org
  2014-12-03 15:52 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-12-03 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #2 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Issue is that lookup_destructor calls adjust_result_of_qualified_name_lookup
with an NULL_TREE decl (returned by lookup_member).  Here the error-check seems
to be missing.

Following patch fixes this issue for me:
Index: typeck.c
===================================================================
--- typeck.c    (Revision 218142)
+++ typeck.c    (Arbeitskopie)
@@ -2536,6 +2536,11 @@ lookup_destructor (tree object, tree scope, tree d
   expr = lookup_member (dtor_type, complete_dtor_identifier,
                        /*protect=*/1, /*want_type=*/false,
                        tf_warning_or_error);
+  if (!expr)
+    {
+      cxx_incomplete_type_error (dtor_name, dtor_type);
+      return error_mark_node;
+    }
   expr = (adjust_result_of_qualified_name_lookup
          (expr, dtor_type, object_type));
   if (scope == NULL_TREE)
Index: search.c
===================================================================
--- search.c    (Revision 218142)
+++ search.c    (Arbeitskopie)
@@ -1530,6 +1530,9 @@ adjust_result_of_qualified_name_lookup (tree decl,
                                        tree qualifying_scope,
                                        tree context_class)
 {
+  if (!decl)
+    return NULL_TREE;
+
   if (context_class && context_class != error_mark_node
       && CLASS_TYPE_P (context_class)
       && CLASS_TYPE_P (qualifying_scope)

The change to search.c isn't really required, but avoids to show the ice in
adjust_result_of_qualifying.


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
  2014-12-03  9:49 ` [Bug c++/64100] " mpolacek at gcc dot gnu.org
  2014-12-03 10:38 ` ktietz at gcc dot gnu.org
@ 2014-12-03 15:52 ` jakub at gcc dot gnu.org
  2014-12-03 21:56 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-03 15:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, r160250 still errored out on it, r160311 already ICEs.


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
                   ` (2 preceding siblings ...)
  2014-12-03 15:52 ` jakub at gcc dot gnu.org
@ 2014-12-03 21:56 ` jason at gcc dot gnu.org
  2014-12-04 11:22 ` ktietz at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-12-03 21:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Kai Tietz from comment #2)
> Following patch fixes this issue for me:

Were you going to send the patch to the list?

> +  if (!expr)
> +    {
> +      cxx_incomplete_type_error (dtor_name, dtor_type);
> +      return error_mark_node;
> +    }

The error needs to be conditional on (complain & tf_error).

Does the caller handle error_mark_node properly?


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
                   ` (3 preceding siblings ...)
  2014-12-03 21:56 ` jason at gcc dot gnu.org
@ 2014-12-04 11:22 ` ktietz at gcc dot gnu.org
  2014-12-10 11:23 ` ktietz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-12-04 11:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #5 from Kai Tietz <ktietz at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #4)
> (In reply to Kai Tietz from comment #2)
> > Following patch fixes this issue for me:
> 
> Were you going to send the patch to the list?

Yes, I will send it today to ML.  I will put you CC.

> > +  if (!expr)
> > +    {
> > +      cxx_incomplete_type_error (dtor_name, dtor_type);
> > +      return error_mark_node;
> > +    }
> 
> The error needs to be conditional on (complain & tf_error).

Ok, I'll add that.

> Does the caller handle error_mark_node properly?

Yes, I tested it before.  By just returning error_mark_node the testcase will
be processed completely silently by g++.


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
                   ` (4 preceding siblings ...)
  2014-12-04 11:22 ` ktietz at gcc dot gnu.org
@ 2014-12-10 11:23 ` ktietz at gcc dot gnu.org
  2014-12-10 11:27 ` ktietz at gcc dot gnu.org
  2014-12-10 16:28 ` ktietz at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-12-10 11:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Author: ktietz
Date: Wed Dec 10 11:22:34 2014
New Revision: 218571

URL: https://gcc.gnu.org/viewcvs?rev=218571&root=gcc&view=rev
Log:
    PR c++/64100
    * typeck.c (lookup_destructor): Handle incomplete type.


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


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
                   ` (5 preceding siblings ...)
  2014-12-10 11:23 ` ktietz at gcc dot gnu.org
@ 2014-12-10 11:27 ` ktietz at gcc dot gnu.org
  2014-12-10 16:28 ` ktietz at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-12-10 11:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

--- Comment #7 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Author: ktietz
Date: Wed Dec 10 11:26:47 2014
New Revision: 218572

URL: https://gcc.gnu.org/viewcvs?rev=218572&root=gcc&view=rev
Log:
    PR c++/64100
    * g++.dg/template/pr64100.C: New file.


Added:
    trunk/gcc/testsuite/g++.dg/template/pr64100.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/64100] A static assert using the the current class in a noexcept test leads to a segfault
  2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
                   ` (6 preceding siblings ...)
  2014-12-10 11:27 ` ktietz at gcc dot gnu.org
@ 2014-12-10 16:28 ` ktietz at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-12-10 16:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64100

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Fixed.  As it is an error on invalid-code, it won't get backported
automatically.  Close it.


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

end of thread, other threads:[~2014-12-10 16:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 10:57 [Bug c++/64100] New: A static assert using the the current class in a noexcept test leads to a segfault ville.voutilainen at gmail dot com
2014-12-03  9:49 ` [Bug c++/64100] " mpolacek at gcc dot gnu.org
2014-12-03 10:38 ` ktietz at gcc dot gnu.org
2014-12-03 15:52 ` jakub at gcc dot gnu.org
2014-12-03 21:56 ` jason at gcc dot gnu.org
2014-12-04 11:22 ` ktietz at gcc dot gnu.org
2014-12-10 11:23 ` ktietz at gcc dot gnu.org
2014-12-10 11:27 ` ktietz at gcc dot gnu.org
2014-12-10 16:28 ` ktietz at gcc dot gnu.org

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).