public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected
@ 2023-04-03  1:43 arthur.j.odwyer at gmail dot com
  2023-04-03  1:47 ` [Bug c++/109381] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2023-04-03  1:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109381
           Summary: Ambiguous member lookup with this-> accepted when it
                    should be rejected
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/ex97db8cT
template<class T>
struct B {
  int f() { return 1; }
};
struct C {
  int f() { return 2; }
};
template<class T>
struct D : B<T>, C {
  int test() {
    return this->f();  // GCC calls C::f; Clang and MSVC reject
  }
};
int main() {
  D<int> d;
  return d.test();
}

This can't possibly be unreported yet, but a quick search failed to find any
bug filed on the subject. Sorry if this is a duplicate.

GCC correctly thinks that `return f();` should call `C::f` because `B<T>::f` is
not considered because `B<T>` is a dependent base class and we didn't say
`this->`.

But, GCC wrongly thinks that `return this->f();` should ALSO call `C::f`. Clang
and MSVC agree that it should be ambiguous, because now it IS looked up in both
phase 1 and phase 2, and an `f` is found in both base classes, so the lookup
should be considered ambiguous.

According to Godbolt, the issue was introduced somewhere between GCC 7.5 (OK)
and GCC 8.1 (buggy).

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

* [Bug c++/109381] [10/11/12/13 Regression] Ambiguous member lookup with this-> accepted when it should be rejected
  2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
@ 2023-04-03  1:47 ` pinskia at gcc dot gnu.org
  2023-04-03  1:49 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-03  1:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |7.5.0
            Summary|Ambiguous member lookup     |[10/11/12/13 Regression]
                   |with this-> accepted when   |Ambiguous member lookup
                   |it should be rejected       |with this-> accepted when
                   |                            |it should be rejected
      Known to fail|                            |13.0, 8.1.0
   Target Milestone|---                         |10.5

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

* [Bug c++/109381] [10/11/12/13 Regression] Ambiguous member lookup with this-> accepted when it should be rejected
  2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
  2023-04-03  1:47 ` [Bug c++/109381] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
@ 2023-04-03  1:49 ` pinskia at gcc dot gnu.org
  2023-04-03 13:24 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-03  1:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
   Last reconfirmed|                            |2023-04-03
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. most likely caused by the way which got it right without this->

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

* [Bug c++/109381] [10/11/12/13 Regression] Ambiguous member lookup with this-> accepted when it should be rejected
  2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
  2023-04-03  1:47 ` [Bug c++/109381] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
  2023-04-03  1:49 ` pinskia at gcc dot gnu.org
@ 2023-04-03 13:24 ` ppalka at gcc dot gnu.org
  2023-04-08 14:32 ` law at gcc dot gnu.org
  2023-07-07 10:45 ` [Bug c++/109381] [11/12/13/14 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-04-03 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
                 CC|                            |ppalka at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=15272

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed. most likely caused by the way which got it right without this->

Yep, started with r8-5270-g2b031ef48e365e.

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

* [Bug c++/109381] [10/11/12/13 Regression] Ambiguous member lookup with this-> accepted when it should be rejected
  2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
                   ` (2 preceding siblings ...)
  2023-04-03 13:24 ` ppalka at gcc dot gnu.org
@ 2023-04-08 14:32 ` law at gcc dot gnu.org
  2023-07-07 10:45 ` [Bug c++/109381] [11/12/13/14 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2023-04-08 14:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |law at gcc dot gnu.org

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

* [Bug c++/109381] [11/12/13/14 Regression] Ambiguous member lookup with this-> accepted when it should be rejected
  2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
                   ` (3 preceding siblings ...)
  2023-04-08 14:32 ` law at gcc dot gnu.org
@ 2023-07-07 10:45 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03  1:43 [Bug c++/109381] New: Ambiguous member lookup with this-> accepted when it should be rejected arthur.j.odwyer at gmail dot com
2023-04-03  1:47 ` [Bug c++/109381] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2023-04-03  1:49 ` pinskia at gcc dot gnu.org
2023-04-03 13:24 ` ppalka at gcc dot gnu.org
2023-04-08 14:32 ` law at gcc dot gnu.org
2023-07-07 10:45 ` [Bug c++/109381] [11/12/13/14 " rguenth 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).