public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification
@ 2020-05-04 15:39 eracpp at eml dot cc
  2020-05-04 15:41 ` [Bug c++/94944] " eracpp at eml dot cc
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: eracpp at eml dot cc @ 2020-05-04 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94944
           Summary: compile error accessing member function of dependent
                    base class template in exception specification
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eracpp at eml dot cc
  Target Milestone: ---

GCC fails to compile a qualified invocation of a member function of a dependent
base class template when used within an exception specification:

----
template <typename T>
struct B {
  void foo(T t) {}
};

template <typename T>
struct D : B<T> {
  void foo(T t) noexcept(noexcept(B<T>::foo(t))) {}
};

template struct D<int>;
----

The error message is as follows:

----
error: cannot call member function 'void B<T>::foo(T) [with T = int]' without
object
    8 |   void foo(T t) noexcept(noexcept(B<T>::foo(t))) {}
      |
----

Clang and MSVC accept the code as given without error:
https://gcc.godbolt.org/z/MW2iQz

Note, a workaround accepted by all three major compilers is to qualify the
invocation with `this->`:

----
void foo(T t) noexcept(noexcept(this->B<T>::foo(t))) {}
----

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in exception specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
@ 2020-05-04 15:41 ` eracpp at eml dot cc
  2020-05-04 15:56 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: eracpp at eml dot cc @ 2020-05-04 15:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from eracpp <eracpp at eml dot cc> ---
The example may be simplified further by removing the function parameters:

----
template <typename T>
struct B {
  void foo() {}
};

template <typename T>
struct D : B<T> {
  void foo() noexcept(noexcept(B<T>::foo())) {}
};

template struct D<int>;
----

Which still yields the same error:

----
error: cannot call member function 'void B<T>::foo() [with T = int]' without
object
    8 |   void foo() noexcept(noexcept(B<T>::foo())) {}
      |
----

And the `this->B<T>::foo()` workaround still applies.

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in exception specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
  2020-05-04 15:41 ` [Bug c++/94944] " eracpp at eml dot cc
@ 2020-05-04 15:56 ` mpolacek at gcc dot gnu.org
  2021-12-09  1:46 ` [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-04 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-05-04
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |rejects-valid
     Ever confirmed|0                           |1

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Not a regression AFAICT.

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
  2020-05-04 15:41 ` [Bug c++/94944] " eracpp at eml dot cc
  2020-05-04 15:56 ` mpolacek at gcc dot gnu.org
@ 2021-12-09  1:46 ` pinskia at gcc dot gnu.org
  2022-02-16 21:14 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09  1:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|compile error accessing     |compile error accessing
                   |member function of          |member function of
                   |dependent base class        |dependent base class
                   |template in exception       |template in noexcept
                   |specification               |specification

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Interesting this works though:
template <typename T>
struct B {
  void foo(T t) {}
};
template <typename T>
struct D : B<T> {
  auto foo(T t) -> decltype(B<T>::foo(t));
};
template struct D<int>;

---- CUT ---

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
                   ` (2 preceding siblings ...)
  2021-12-09  1:46 ` [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification pinskia at gcc dot gnu.org
@ 2022-02-16 21:14 ` pinskia at gcc dot gnu.org
  2022-02-17 14:14 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-16 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oliver.rosten at googlemail dot co
                   |                            |m

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 104575 has been marked as a duplicate of this bug. ***

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
                   ` (3 preceding siblings ...)
  2022-02-16 21:14 ` pinskia at gcc dot gnu.org
@ 2022-02-17 14:14 ` ppalka at gcc dot gnu.org
  2022-02-18  1:22 ` cvs-commit at gcc dot gnu.org
  2022-02-18  1:24 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-17 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
                   ` (4 preceding siblings ...)
  2022-02-17 14:14 ` ppalka at gcc dot gnu.org
@ 2022-02-18  1:22 ` cvs-commit at gcc dot gnu.org
  2022-02-18  1:24 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-18  1:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:36278f48cbc08c78e4ed588e5a049bd45fd1c55a

commit r12-7291-g36278f48cbc08c78e4ed588e5a049bd45fd1c55a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Feb 17 20:20:24 2022 -0500

    c++: implicit 'this' in noexcept-spec within class tmpl [PR94944]

    Here when instantiating the noexcept-spec we fail to resolve the
    implicit object for the member call A<T>::f() ultimately because
    maybe_instantiate_noexcept sets current_class_ptr/ref to the dependent
    'this' (of type B<T>) rather than the specialized 'this' (of type B<int>).

    This patch fixes this by making maybe_instantiate_noexcept set
    current_class_ptr/ref to the specialized 'this' instead, consistent
    with what tsubst_function_type does when substituting into the trailing
    return type of a non-static member function.

            PR c++/94944

    gcc/cp/ChangeLog:

            * pt.cc (maybe_instantiate_noexcept): For non-static member
            functions, set current_class_ptr/ref to the specialized 'this'
            instead.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/noexcept34.C: Adjusted expected diagnostics.
            * g++.dg/cpp0x/noexcept75.C: New test.

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

* [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification
  2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
                   ` (5 preceding siblings ...)
  2022-02-18  1:22 ` cvs-commit at gcc dot gnu.org
@ 2022-02-18  1:24 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-18  1:24 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |12.0

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12, thanks for the bug report.

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

end of thread, other threads:[~2022-02-18  1:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 15:39 [Bug c++/94944] New: compile error accessing member function of dependent base class template in exception specification eracpp at eml dot cc
2020-05-04 15:41 ` [Bug c++/94944] " eracpp at eml dot cc
2020-05-04 15:56 ` mpolacek at gcc dot gnu.org
2021-12-09  1:46 ` [Bug c++/94944] compile error accessing member function of dependent base class template in noexcept specification pinskia at gcc dot gnu.org
2022-02-16 21:14 ` pinskia at gcc dot gnu.org
2022-02-17 14:14 ` ppalka at gcc dot gnu.org
2022-02-18  1:22 ` cvs-commit at gcc dot gnu.org
2022-02-18  1:24 ` ppalka 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).