[llvm-bugs] [Bug 41995] New: [N2439] Clang does NOT issue a diagnostic on ill-formed overloaded member functions

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 23 08:04:42 PDT 2019


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

            Bug ID: 41995
           Summary: [N2439] Clang does NOT issue a diagnostic on
                    ill-formed overloaded member functions
           Product: clang
           Version: 8.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pclove1 at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

# Overview:

According to
[N2439](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm),
> Member function declarations with the same name and the same parameter-type-list, as well as member function template declarations with the same name, the same parameter-type-list, and the same template parameter lists, cannot be overloaded if any of them, but not all, have a ref-qualifier (8.3.5).

# Steps to Reproduce:
```
class Base {
public:
  void f() const {}
};

class Derived : public Base {
public:
  using Base::f;
  void f() & {}
  void f() && {}
};


int main() {
  const Derived cd;
  cd.f();

  return 0;
}

```

# Actual Results: 
Clang compiles the above example without a diagnostic.

# Expected Results:
Clang issues a diagnostic.

# Build Date & Hardware:
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

# Additional Information:
- godbolt link to explore the example online.
  - https://godbolt.org/z/vEYRIU

- x86-64 gcc 9.1 issues a diagnostic on the above example.
```
<source>: In function 'int square(int)':

<source>:15:10: error: passing 'const Derived' as 'this' argument discards
qualifiers [-fpermissive]

   15 |     cd.f();

      |          ^

<source>:9:7: note:   in call to 'int Derived::f() &'

    9 |   int f() & { return 2; }

      |       ^

Compiler returned: 1
```

-- 
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/20190523/a7b7b4f9/attachment.html>


More information about the llvm-bugs mailing list