public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd
@ 2012-08-09 11:04 andrewjcg at gmail dot com
  2012-08-09 11:39 ` [Bug c++/54207] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: andrewjcg at gmail dot com @ 2012-08-09 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54207
           Summary: ICE in build_noexcept_spec when bool is
                    #defined/typedef'd
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: andrewjcg@gmail.com


This ICE occurs under unique/odd but reproducible conditions.  The key
components of the environment for this bug appear to be:
1. 'bool' is typedef'd to a new type which is then #define'd over the existing
'bool' type (this is the case in the common.h head from the ldns package,
http://www.nlnetlabs.nl/projects/ldns/).
2. A user-defined class inherits from a templated base class, like
std::vector<string>.
3. This same class calls a noexcept method on a vector member (which appears to
trigger the build_noexcept_spec function).

This bug is reproducible with the following code on gcc-4.7.  It compiles
without error on gcc-4.6:

----------------------------------------------

typedef bool _Bool;
# define bool _Bool

#include <vector>
#include <iostream>
#include <cstring>
using namespace std;

class Test : public vector<string> {
public:
  Test (Test& that) {
    arr = std::move(that.arr);
  }
private:
  std::vector<int*> arr;
};


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

* [Bug c++/54207] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
@ 2012-08-09 11:39 ` redi at gcc dot gnu.org
  2012-10-06  0:15 ` [Bug c++/54207] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-09 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-09 11:39:10 UTC ---
4.7.1 gets an ICE too, but it works on trunk.

As it's undefined behaviour (bool is a keyword) and it already works on trunk
it might not be worth changing anything.


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

* [Bug c++/54207] [4.7/4.8 Regression] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
  2012-08-09 11:39 ` [Bug c++/54207] " redi at gcc dot gnu.org
@ 2012-10-06  0:15 ` paolo.carlini at oracle dot com
  2012-11-19 12:50 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-06  0:15 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-06
            Summary|ICE in build_noexcept_spec  |[4.7/4.8 Regression] ICE in
                   |when bool is                |build_noexcept_spec when
                   |#defined/typedef'd          |bool is #defined/typedef'd
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-06 00:14:48 UTC ---
Confirmed as a regression with r192148. A minor issue IMHO too.


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

* [Bug c++/54207] [4.7/4.8 Regression] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
  2012-08-09 11:39 ` [Bug c++/54207] " redi at gcc dot gnu.org
  2012-10-06  0:15 ` [Bug c++/54207] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
@ 2012-11-19 12:50 ` jakub at gcc dot gnu.org
  2012-12-03 15:41 ` [Bug c++/54207] [4.7/4.8 Regression][C++0x] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-19 12:50 UTC (permalink / raw)
  To: gcc-bugs


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

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

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


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

* [Bug c++/54207] [4.7/4.8 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (2 preceding siblings ...)
  2012-11-19 12:50 ` jakub at gcc dot gnu.org
@ 2012-12-03 15:41 ` rguenth at gcc dot gnu.org
  2012-12-04 11:09 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:41 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
           Priority|P3                          |P2
      Known to work|                            |4.6.3
            Summary|[4.7/4.8 Regression] ICE in |[4.7/4.8 Regression][C++0x]
                   |build_noexcept_spec when    |ICE in build_noexcept_spec
                   |bool is #defined/typedef'd  |when bool is
                   |                            |#defined/typedef'd
      Known to fail|                            |4.7.2, 4.8.0

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 15:40:35 UTC ---
ICEs with -std=c++0x only, also ICEs on trunk.


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

* [Bug c++/54207] [4.7/4.8 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (3 preceding siblings ...)
  2012-12-03 15:41 ` [Bug c++/54207] [4.7/4.8 Regression][C++0x] " rguenth at gcc dot gnu.org
@ 2012-12-04 11:09 ` jakub at gcc dot gnu.org
  2012-12-06 18:56 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-04 11:09 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-04 11:08:04 UTC ---
Created attachment 28874
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28874
gcc48-pr54207.patch

The testcase is invalid, you can't add typedefs with system reserved names
before including standard headers, nor redefine keywords to something else.

That said, in this patch is a testcase which IMHO is valid and still ICEs even
with current trunk.

The thing is that perform_implicit_conversion will not do anything if the type
is same_type_p, but different (B vs. bool in this testcase, _Bool vs. bool in
the original testcase).  In both cases the other type is also a BOOLEAN_TYPE,
but distinct from the original one.  Doing == boolean_true_node or ==
boolean_false_node comparison doesn't work in that case, they aren't pointer
equal (as they have distinct type), yet they operand_equal_p true.  So, either
we use operand_equal_p as this patch does (the patch guards it with INTEGER_CST
check to avoid calling operand_equal_p unnecessarily, but that can be certainly
dropped and done unconditionally if Jason prefers that), or we could for
INTEGER_CSTs fold_convert them to boolean_type_node, then the pointer equality
comparison would work.


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

* [Bug c++/54207] [4.7/4.8 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (4 preceding siblings ...)
  2012-12-04 11:09 ` jakub at gcc dot gnu.org
@ 2012-12-06 18:56 ` jakub at gcc dot gnu.org
  2012-12-06 19:16 ` [Bug c++/54207] [4.7 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-06 18:56 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-06 18:55:52 UTC ---
Author: jakub
Date: Thu Dec  6 18:55:48 2012
New Revision: 194263

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194263
Log:
    PR c++/54207
    * except.c (build_noexcept_spec): Avoid direct comparison
    with boolean_true_node or boolean_false_node, instead use
    operand_equal_p and/or INTEGER_CST check.
    * pt.c (tsubst_exception_specification): Likewise.
    * typeck2.c (merge_exception_specifiers): Likewise.

    * g++.dg/cpp0x/noexcept18.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept18.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/except.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/54207] [4.7 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (5 preceding siblings ...)
  2012-12-06 18:56 ` jakub at gcc dot gnu.org
@ 2012-12-06 19:16 ` jakub at gcc dot gnu.org
  2013-02-01 14:06 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-06 19:16 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.0
            Summary|[4.7/4.8 Regression][C++0x] |[4.7 Regression][C++0x] ICE
                   |ICE in build_noexcept_spec  |in build_noexcept_spec when
                   |when bool is                |bool is #defined/typedef'd
                   |#defined/typedef'd          |
      Known to fail|4.8.0                       |

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-06 19:15:54 UTC ---
Fixed on the trunk so far.


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

* [Bug c++/54207] [4.7 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (6 preceding siblings ...)
  2012-12-06 19:16 ` [Bug c++/54207] [4.7 " jakub at gcc dot gnu.org
@ 2013-02-01 14:06 ` jakub at gcc dot gnu.org
  2013-02-01 14:28 ` jakub at gcc dot gnu.org
  2013-06-10 15:46 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-02-01 14:06 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-01 14:05:55 UTC ---
Author: jakub
Date: Fri Feb  1 14:05:42 2013
New Revision: 195653

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195653
Log:
    Backported from mainline
    2012-12-13  Jakub Jelinek  <jakub@redhat.com>

    PR c++/55652
    * typeck2.c (merge_exception_specifiers): Don't call operand_equal_p
    if noex is NULL.

    * g++.dg/cpp0x/noexcept19.C: New test.

    2012-12-06  Jakub Jelinek  <jakub@redhat.com>

    PR c++/54207
    * except.c (build_noexcept_spec): Avoid direct comparison
    with boolean_true_node or boolean_false_node, instead use
    operand_equal_p and/or INTEGER_CST check.
    * pt.c (tsubst_exception_specification): Likewise.
    * typeck2.c (merge_exception_specifiers): Likewise.

    * g++.dg/cpp0x/noexcept18.C: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/noexcept18.C
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/noexcept19.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/except.c
    branches/gcc-4_7-branch/gcc/cp/pt.c
    branches/gcc-4_7-branch/gcc/cp/typeck2.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/54207] [4.7 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (7 preceding siblings ...)
  2013-02-01 14:06 ` jakub at gcc dot gnu.org
@ 2013-02-01 14:28 ` jakub at gcc dot gnu.org
  2013-06-10 15:46 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-02-01 14:28 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.7.3
         Resolution|                            |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-01 14:27:53 UTC ---
Fixed.


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

* [Bug c++/54207] [4.7 Regression][C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd
  2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
                   ` (8 preceding siblings ...)
  2013-02-01 14:28 ` jakub at gcc dot gnu.org
@ 2013-06-10 15:46 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-10 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ai.azuma at gmail dot com

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 52371 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2013-06-10 15:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-09 11:04 [Bug c++/54207] New: ICE in build_noexcept_spec when bool is #defined/typedef'd andrewjcg at gmail dot com
2012-08-09 11:39 ` [Bug c++/54207] " redi at gcc dot gnu.org
2012-10-06  0:15 ` [Bug c++/54207] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
2012-11-19 12:50 ` jakub at gcc dot gnu.org
2012-12-03 15:41 ` [Bug c++/54207] [4.7/4.8 Regression][C++0x] " rguenth at gcc dot gnu.org
2012-12-04 11:09 ` jakub at gcc dot gnu.org
2012-12-06 18:56 ` jakub at gcc dot gnu.org
2012-12-06 19:16 ` [Bug c++/54207] [4.7 " jakub at gcc dot gnu.org
2013-02-01 14:06 ` jakub at gcc dot gnu.org
2013-02-01 14:28 ` jakub at gcc dot gnu.org
2013-06-10 15:46 ` paolo.carlini at oracle dot com

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