[Bug c++/97772] New: Wording of GCC's error message when calling lvalue-ref qualified member function on temporary object

enricomaria.dean6elis at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Nov 10 06:12:11 GMT 2020


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

            Bug ID: 97772
           Summary: Wording of GCC's error message when calling lvalue-ref
                    qualified member function on temporary object
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enricomaria.dean6elis at gmail dot com
  Target Milestone: ---

Long story short, write this source file

struct A {
    void doWork() & {}
};
int main() {
    A{}.doWork();
}

compile it with

g++ -std=c++17 that_file.cpp

and the error will be

error: passing ‘A’ as ‘this’ argument discards qualifiers [-fpermissive]

There's really no discarded qualifier; it's just that `A{}` cannot bind to the
`&`-qualified overload.

The full discussion is on StackOverflow at
https://stackoverflow.com/q/64705932/5825294


More information about the Gcc-bugs mailing list