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

            Bug ID: 110097
           Summary: Error invalid use of non-static member function
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bmlushma at uwaterloo dot ca
  Target Milestone: ---

Created attachment 55243
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55243&action=edit
Preprocessed *.i* files

g++-11 -std=c++20 -fmodules-ts test.cc -x c++-system-header iostream

text.cc:

import <iostream>;
int main() {
    std::istream * infile;
    delete infile;
}


This is going to be UB at run-time, but should not produce a compiler error,
let alone the one we got.

Compiler output:

test.cc: In function ‘int main()’:
test.cc:4:12: error: invalid use of non-static member function
‘std::basic_istream<_CharT, _Traits>::~basic_istream() [with _CharT = char;
_Traits = std::char_traits<char>]’
    4 |     delete infile;
      |            ^~~~~~
In file included from /usr/include/c++/11/iostream:40,
of module /usr/include/c++/11/iostream, imported at test.cc:1:
/usr/include/c++/11/istream:103:7: note: declared here
  103 |       ~basic_istream()
      |       ^

Reply via email to