[Bug c++/70621] New: ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] New: ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

            Bug ID: 70621
           Summary: ICE on invalid code at -O1 and above on
                    x86_64-linux-gnu in record_reference, at
                    cgraphbuild.c:64
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following code causes an ICE when compiled with the current GCC trunk at
-O1 and above on x86_64-linux-gnu in both 32-bit and 64-bit modes.  

This is a regression from 5.3.x.


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 6.0.0 20160410 (experimental) [trunk revision 234869] (GCC)
$
$ g++-trunk -O0 -c small.cpp
small.cpp:30:12: error: conflicting declaration ‘const B D::e’
 const B D::e = { 0, (fp) &E::foo };
            ^
small.cpp:20:12: note: previous declaration as ‘B D::e’
   static B e;
            ^
small.cpp:30:12: error: declaration of ‘B D::e’ outside of class is not
definition [-fpermissive]
 const B D::e = { 0, (fp) &E::foo };
            ^
$
$ g++-5.3 -O1 -c small.cpp
small.cpp:30:12: error: conflicting declaration ‘const B D::e’
 const B D::e = { 0, (fp) &E::foo };
            ^
small.cpp:20:12: note: previous declaration as ‘B D::e’
   static B e;
            ^
small.cpp:30:12: error: declaration of ‘B D::e’ outside of class is not
definition [-fpermissive]
 const B D::e = { 0, (fp) &E::foo };
            ^
$
$ g++-trunk -O1 -c small.cpp
small.cpp:30:12: error: conflicting declaration ‘const B D::e’
 const B D::e = { 0, (fp) &E::foo };
            ^
small.cpp:20:12: note: previous declaration as ‘B D::e’
   static B e;
            ^
small.cpp:30:12: error: declaration of ‘B D::e’ outside of class is not
definition [-fpermissive]
 const B D::e = { 0, (fp) &E::foo };
            ^
cc1plus: internal compiler error: in record_reference, at cgraphbuild.c:64
0x95ef53 record_reference
        ../../gcc-source-trunk/gcc/cgraphbuild.c:64
0x100fec4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set<tree_node*, default_hash_traits<tree_node*> >*))
        ../../gcc-source-trunk/gcc/tree.c:11531
0x1010474 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set<tree_node*, default_hash_traits<tree_node*> >*))
        ../../gcc-source-trunk/gcc/tree.c:11848
0x1010474 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set<tree_node*, default_hash_traits<tree_node*> >*))
        ../../gcc-source-trunk/gcc/tree.c:11848
0x96008a record_references_in_initializer(tree_node*, bool)
        ../../gcc-source-trunk/gcc/cgraphbuild.c:404
0x1051957 varpool_node::analyze()
        ../../gcc-source-trunk/gcc/varpool.c:526
0x966359 analyze_functions
        ../../gcc-source-trunk/gcc/cgraphunit.c:1133
0x966f98 symbol_table::finalize_compilation_unit()
        ../../gcc-source-trunk/gcc/cgraphunit.c:2542
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$


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


class A;

typedef void (A::*fp) (void);

struct B
{
  int n;
  fp f;
};

struct C
{
  const C *c;
  const B b;
};

class D
{
public:
  static B e;
  static C m;
};

class E : public D
{
public:
  void foo ();
};

// OK: B D::e = { 0, (fp) &E::foo };
const B D::e = { 0, (fp) &E::foo };

C D::m = { &D::m, E::e };
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |error-recovery
   Last reconfirmed|                            |2016-04-11
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
            Summary|ICE on invalid code at -O1  |[6 Regression] ICE on
                   |and above on                |invalid code at -O1 and
                   |x86_64-linux-gnu in         |above on x86_64-linux-gnu
                   |record_reference, at        |in record_reference, at
                   |cgraphbuild.c:64            |cgraphbuild.c:64
   Target Milestone|---                         |6.0

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with my r232278 aka PR68511 and PR69213 fix.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is unfortunate that due to the Cilk+ bug it is hard to bisect this properly.
Anyway, looking at what 5.x does I see a major difference of r229018, we used
to modify the initializer (apparently in-place), but we no longer do and the
PTRMEM_CST remains in the IL until the ME.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.0                         |6.2

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6.1 has been released.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.2                         |6.3

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.2                         |6.3

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.3                         |6.4

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6.3 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

Volker Reichelt <reichelt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2016-04-11 00:00:00         |2017-06-07
                 CC|                            |reichelt at gcc dot gnu.org

--- Comment #10 from Volker Reichelt <reichelt at gcc dot gnu.org> ---
Here's an even simpler example that ICEs since GCC 4.9.0:

=========================
float foo();

struct A
{
  static float x;
};

double A::x = foo();

void bar()
{
  A::x = 0;
}
=========================

bug.cc:8:11: error: conflicting declaration 'double A::x'
 double A::x = foo();
           ^
bug.cc:5:16: note: previous declaration as 'float A::x'
   static float x;
                ^
bug.cc:8:11: error: declaration of 'float A::x' outside of class is not
definition [-fpermissive]
 double A::x = foo();
           ^
cc1plus: internal compiler error: in record_reference, at cgraphbuild.c:64
0x96b754 record_reference
        ../../gcc/gcc/cgraphbuild.c:64
0x1048663 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set<tree_node*, default_hash_traits<tree_node*> >*))
        ../../gcc/gcc/tree.c:11838
0x1048ef2 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set<tree_node*, default_hash_traits<tree_node*> >*))
        ../../gcc/gcc/tree.c:12155
0x96c952 record_references_in_initializer(tree_node*, bool)
        ../../gcc/gcc/cgraphbuild.c:401
0x1088e07 varpool_node::analyze()
        ../../gcc/gcc/varpool.c:532
0x972916 analyze_functions
        ../../gcc/gcc/cgraphunit.c:1180
0x973cc2 symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2611
Please submit a full bug report, [etc.]
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.4                         |6.5

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.4 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> ---
On it.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

--- Comment #13 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue Sep 12 19:45:37 2017
New Revision: 252040

URL: https://gcc.gnu.org/viewcvs?rev=252040&root=gcc&view=rev
Log:
/cp
2017-09-12  Paolo Carlini  <[hidden email]>

        PR c++/70621
        * decl.c (start_decl): Early return error_mark_node if duplicate_decls
        returns it; avoid misleading error message.

/testsuite
2017-09-12  Paolo Carlini  <[hidden email]>

        PR c++/70621
        * g++.dg/torture/pr70621.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr70621.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[6/7/8 Regression] ICE on   |[6/7 Regression] ICE on
                   |invalid code at -O1 and     |invalid code at -O1 and
                   |above on x86_64-linux-gnu   |above on x86_64-linux-gnu
                   |in record_reference, at     |in record_reference, at
                   |cgraphbuild.c:64            |cgraphbuild.c:64

--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed in trunk so far.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [6/7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.5                         |7.4

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.4                         |7.5
Reply | Threaded
Open this post in threaded view
|

[Bug c++/70621] [7 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70621

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |8.1.0
         Resolution|---                         |FIXED
   Target Milestone|7.5                         |8.0
      Known to fail|                            |7.5.0

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC8.