public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106890] New: virtual inheritance triggers compiler error when instatiating derived class with in-class initialization
@ 2022-09-08 10:06 thomas at thomaslabs dot org
  2022-09-08 10:12 ` [Bug c++/106890] [10/11/12/13 Regression] virtual inheritance triggers compiler error when instatiating derived class with in-class initialization since r8-2709-g12659e10c7820071 marxin at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: thomas at thomaslabs dot org @ 2022-09-08 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106890
           Summary: virtual inheritance triggers compiler error when
                    instatiating derived class with in-class
                    initialization
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thomas at thomaslabs dot org
  Target Milestone: ---

Created attachment 53549
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53549&action=edit
The exact source code used to trigger the error

The following code sample triggers an internal compiler error. This happends
when using the virtual keyword in the definition of B and is related to the
function call to f inside the class definition. When later attempting to
instantiate the class B the compiler fails.

I'm working with GCC version 12.2.0 but this bug seems to be present as early
as version 8.5.0. Version 7.5.0 managed to compile without a problem.

* Command line 

g++ bug.cpp

* Compiler output:

during RTL pass: expand
bug.cpp: In constructor ‘B<T>::B(int) [with T = int]’:
bug.cpp:26:5: internal compiler error: in expand_expr_real_1, at expr.cc:10586
   26 |     B(int a) {
      |     ^
0x1b286a6 internal_error(char const*, ...)
        ???:0
0x6ccc1e fancy_abort(char const*, int, char const*)
        ???:0

* Compiler version:

GNU C++17 (GCC) version 12.2.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP

* System

GNU/Guix x86_64

* Source code

class O
{
public:
    int f() {
        return 1;
    }
};

template<typename T>
class A
{
public:
    A();
    A(int a);

protected:
    O p = O();
};

template<typename T>
class B : virtual public A<T>
{
public:
    B() {
    }
    B(int a) {
    }

protected:
    using A<T>::p;
    unsigned int k = p.f();
};

template class B<int>;

int main()
{
    return 0;
}

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

end of thread, other threads:[~2023-09-11 22:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 10:06 [Bug c++/106890] New: virtual inheritance triggers compiler error when instatiating derived class with in-class initialization thomas at thomaslabs dot org
2022-09-08 10:12 ` [Bug c++/106890] [10/11/12/13 Regression] virtual inheritance triggers compiler error when instatiating derived class with in-class initialization since r8-2709-g12659e10c7820071 marxin at gcc dot gnu.org
2022-09-08 10:49 ` rguenth at gcc dot gnu.org
2022-10-19  5:55 ` rguenth at gcc dot gnu.org
2023-03-17 23:16 ` jason at gcc dot gnu.org
2023-03-21 15:09 ` cvs-commit at gcc dot gnu.org
2023-04-18 20:46 ` [Bug c++/106890] [10/11/12 " cvs-commit at gcc dot gnu.org
2023-07-07 10:43 ` [Bug c++/106890] [11 " rguenth at gcc dot gnu.org
2023-08-11 21:21 ` cvs-commit at gcc dot gnu.org
2023-09-11 22:11 ` cvs-commit at gcc dot gnu.org
2023-09-11 22:11 ` jason 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).