[llvm-bugs] [Bug 51544] New: [concepts] Can template / constraint functions be inherited?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 19 11:10:54 PDT 2021


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

            Bug ID: 51544
           Summary: [concepts] Can template / constraint functions be
                    inherited?
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at marehr.dialup.fu-berlin.de
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hi clang-team,

I'm not sure if this is a defect or standard behaviour, but the following code
compiles with gcc, but not with clang:

```cpp
#include <concepts>

#ifndef MODE
#define MODE 0
#endif

struct base {
#if MODE == 0
  void foo(float target){};
#elif MODE == 1
  template <typename target_t>
  void foo(target_t target){};
#elif MODE == 2
  template <std::floating_point target_t>
  void foo(target_t target){};
#endif
};
struct bar : public base {
  using base::foo;

  template <std::integral target_t>
  void foo(target_t target){};
};
int main() {
  bar f{};
  f.foo(float{});
}

```

https://godbolt.org/z/GGjbqdbvq

MODE  | 0 | 1 | 2 |
------|---|---|---|
gcc   | ✓ | ✓ | ✓ |
clang | ✓ | ✗ | ✗ |
msvc  | ✓ | ✗ | ✗ |

I'm unsure if constructs like this are even allowed.

Thank you!

-- 
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/20210819/a2d4a776/attachment-0001.html>


More information about the llvm-bugs mailing list