[llvm-bugs] [Bug 41309] New: member functions shadow template arguments resulting in "reference to non-static member function must be called" error

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 29 10:26:26 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41309

            Bug ID: 41309
           Summary: member functions shadow template arguments resulting
                    in "reference to non-static member function must be
                    called" error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: peter at pcc.me.uk
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

We reject

$ cat template-test.cpp 
struct S {
  template <bool foo> void f();
  void foo();
};

template <bool foo> void S::f() {
  bool b = foo;
}

void instantiate() {
  S s;
  s.f<true>();
}

with:

template-test.cpp:7:12: error: reference to non-static member function must be
called; did you mean to call it with no arguments?
  bool b = foo;
           ^~~
              ()
template-test.cpp:7:8: error: cannot initialize a variable of type 'bool' with
an rvalue of type 'void'
  bool b = foo;
       ^   ~~~
2 errors generated.

gcc/MSVC/icc all seem to accept it. I haven't checked the standard to see
whether we're getting this right and all the other compilers are getting it
wrong, but I'd be surprised if that were the case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190329/c5f0ba87/attachment-0001.html>


More information about the llvm-bugs mailing list