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

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).