public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class
@ 2022-05-17 20:40 ted at lyncon dot se
2022-05-17 20:55 ` [Bug c++/105637] [12/13 " ppalka at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: ted at lyncon dot se @ 2022-05-17 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Bug ID: 105637
Summary: [11 Regression] Wrong overload selected in base class
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ted at lyncon dot se
Target Milestone: ---
This compiles fine in 11.3 but selects the non-const `BaseClass` overload in
12.1:
```
struct BaseClass {
// Commenting out this non-const function out will fix the compilation:
int baseDevice() { return 1; }
int baseDevice() const { return 2; }
};
template <class ObjectClass>
struct DerivedClass : BaseClass {};
template <class ObjectClass>
struct TopClass : DerivedClass<ObjectClass> {
public:
virtual int failsToCompile() const {
// This should choose to call the const function, but it tries to call
// the non-const version.
return BaseClass::baseDevice(); // error!
//return this->baseDevice(); // works
//return DerivedClass<ObjectClass>::baseDevice(); // works
}
};
int main() {
TopClass<int> x;
}
```
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12/13 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
@ 2022-05-17 20:55 ` ppalka at gcc dot gnu.org
2022-05-18 2:38 ` john.robert.lefebvre at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-17 20:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-05-17
Summary|[12 Regression] Wrong |[12/13 Regression] Wrong
|overload selected in base |overload selected in base
|class |class
Target Milestone|--- |12.2
Known to work| |11.3.0
Ever confirmed|0 |1
CC| |ppalka at gcc dot gnu.org
Known to fail| |12.1.0, 13.0
Keywords| |rejects-valid
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r12-6075-g2decd2cabe5a4f.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12/13 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
2022-05-17 20:55 ` [Bug c++/105637] [12/13 " ppalka at gcc dot gnu.org
@ 2022-05-18 2:38 ` john.robert.lefebvre at gmail dot com
2022-05-18 12:39 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: john.robert.lefebvre at gmail dot com @ 2022-05-18 2:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Rob Lefebvre <john.robert.lefebvre at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |john.robert.lefebvre@gmail.
| |com
--- Comment #2 from Rob Lefebvre <john.robert.lefebvre at gmail dot com> ---
This came from my project via a stack overflow post. Thanks to Ted for
submitting it. FYI, this is from an older version of the Teigha DXF libraries,
now called Drawings I think, https://www.opendesign.com/products/drawings.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12/13 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
2022-05-17 20:55 ` [Bug c++/105637] [12/13 " ppalka at gcc dot gnu.org
2022-05-18 2:38 ` john.robert.lefebvre at gmail dot com
@ 2022-05-18 12:39 ` rguenth at gcc dot gnu.org
2022-06-03 16:07 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-18 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12/13 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (2 preceding siblings ...)
2022-05-18 12:39 ` rguenth at gcc dot gnu.org
@ 2022-06-03 16:07 ` cvs-commit at gcc dot gnu.org
2022-06-03 16:08 ` [Bug c++/105637] [12 " ppalka at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-03 16:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
--- Comment #3 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:44a5bd6d933d86ed988fc4695aa00f122cf83eb4
commit r13-984-g44a5bd6d933d86ed988fc4695aa00f122cf83eb4
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Jun 3 12:06:59 2022 -0400
c++: cv-quals of dummy obj for non-dep memfn call [PR105637]
In non-dependent23.C below we expect the Base::foo calls to
resolve to the second, third and fourth overloads respectively in light
of the cv-qualifiers of 'this' in each case. But ever since
r12-6075-g2decd2cabe5a4f, the calls incorrectly resolve to the first
overload at instantiation time.
This happens because the calls to Base::foo are all deemed
non-dependent (ever since r7-755-g23cb72663051cd made us ignore 'this'
dependence when considering the dependence of a non-static memfn call),
hence we end up checking the call ahead of time, using as the object
argument a dummy object of type Base. Since this object argument is
cv-unqualified, the calls in turn resolve to the unqualified overload
of baseDevice. Before r12-6075 this incorrect result would just get
silently discarded and we'd end up redoing OR at instantiation time
using 'this' as the object argument. But after r12-6075 we now reuse
this incorrect result at instantiation time.
This patch fixes this by making maybe_dummy_object respect the cv-quals
of (the non-lambda) 'this' when returning a dummy object. Thus, ahead
of time OR using a dummy object will give us the right answer that's
consistent with the instantiation time answer.
An earlier version of this patch didn't handle 'this'-capturing lambdas
correctly, which broke lambda-this22.C below.
PR c++/105637
gcc/cp/ChangeLog:
* tree.cc (maybe_dummy_object): When returning a dummy
object, respect the cv-quals of 'this' if available.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-this22.C: New test.
* g++.dg/template/non-dependent23.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (3 preceding siblings ...)
2022-06-03 16:07 ` cvs-commit at gcc dot gnu.org
@ 2022-06-03 16:08 ` ppalka at gcc dot gnu.org
2022-06-03 16:09 ` ted at lyncon dot se
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-03 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13 Regression] Wrong |[12 Regression] Wrong
|overload selected in base |overload selected in base
|class |class
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (4 preceding siblings ...)
2022-06-03 16:08 ` [Bug c++/105637] [12 " ppalka at gcc dot gnu.org
@ 2022-06-03 16:09 ` ted at lyncon dot se
2022-06-03 16:17 ` john.robert.lefebvre at gmail dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ted at lyncon dot se @ 2022-06-03 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
--- Comment #5 from Ted Lyngmo <ted at lyncon dot se> ---
Excellent and thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (5 preceding siblings ...)
2022-06-03 16:09 ` ted at lyncon dot se
@ 2022-06-03 16:17 ` john.robert.lefebvre at gmail dot com
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:50 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: john.robert.lefebvre at gmail dot com @ 2022-06-03 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
--- Comment #6 from Rob Lefebvre <john.robert.lefebvre at gmail dot com> ---
Thank you!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (6 preceding siblings ...)
2022-06-03 16:17 ` john.robert.lefebvre at gmail dot com
@ 2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:50 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:41487bff13fa98607ab5548bc1a0dca71147a5ac
commit r12-8603-g41487bff13fa98607ab5548bc1a0dca71147a5ac
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Jun 3 12:06:59 2022 -0400
c++: cv-quals of dummy obj for non-dep memfn call [PR105637]
In non-dependent23.C below we expect the Base::foo calls to
resolve to the second, third and fourth overloads respectively in light
of the cv-qualifiers of 'this' in each case. But ever since
r12-6075-g2decd2cabe5a4f, the calls incorrectly resolve to the first
overload at instantiation time.
This happens because the calls to Base::foo are all deemed
non-dependent (ever since r7-755-g23cb72663051cd made us ignore 'this'
dependence when considering the dependence of a non-static memfn call),
hence we end up checking the call ahead of time, using as the object
argument a dummy object of type Base. Since this object argument is
cv-unqualified, the calls in turn resolve to the unqualified overload
of baseDevice. Before r12-6075 this incorrect result would just get
silently discarded and we'd end up redoing OR at instantiation time
using 'this' as the object argument. But after r12-6075 we now reuse
this incorrect result at instantiation time.
This patch fixes this by making maybe_dummy_object respect the cv-quals
of (the non-lambda) 'this' when returning a dummy object. Thus, ahead
of time OR using a dummy object will give us the right answer that's
consistent with the instantiation time answer.
An earlier version of this patch didn't handle 'this'-capturing lambdas
correctly, which broke lambda-this22.C below.
PR c++/105637
gcc/cp/ChangeLog:
* tree.cc (maybe_dummy_object): When returning a dummy
object, respect the cv-quals of 'this' if available.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-this22.C: New test.
* g++.dg/template/non-dependent23.C: New test.
(cherry picked from commit 44a5bd6d933d86ed988fc4695aa00f122cf83eb4)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/105637] [12 Regression] Wrong overload selected in base class
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
` (7 preceding siblings ...)
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
@ 2022-07-21 16:50 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-21 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105637
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.2/13
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-07-21 16:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 20:40 [Bug c++/105637] New: [11 Regression] Wrong overload selected in base class ted at lyncon dot se
2022-05-17 20:55 ` [Bug c++/105637] [12/13 " ppalka at gcc dot gnu.org
2022-05-18 2:38 ` john.robert.lefebvre at gmail dot com
2022-05-18 12:39 ` rguenth at gcc dot gnu.org
2022-06-03 16:07 ` cvs-commit at gcc dot gnu.org
2022-06-03 16:08 ` [Bug c++/105637] [12 " ppalka at gcc dot gnu.org
2022-06-03 16:09 ` ted at lyncon dot se
2022-06-03 16:17 ` john.robert.lefebvre at gmail dot com
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:50 ` 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).