[llvm-bugs] [Bug 48222] New: Default argument of constexpr functions not usable in template using?

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 18 15:48:43 PST 2020


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

            Bug ID: 48222
           Summary: Default argument of constexpr functions not usable in
                    template using?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lf-bt at thax.hardliners.org
                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

See the following code. 
The error message is not helpful, either: the default argument is declared
earlier, and when given explicitly (-> workaround) the compiler has no
problems.

--- also https://godbolt.org/z/1b7h6b :

struct foo {
  static constexpr int max(int idx, int min = 0) {
    return (idx > min) ? idx : min;
  }

  template <int I>
  using slice = decltype(max(I)); // fails only in clang
//  using slice = decltype(max(2));  // also fails in gcc trunk, but not gcc
10.2
//  using slice = decltype(max(2, 0));  // workaround
};

---

<source>:7:26: error: use of default argument to function 'max' that is
declared later in class 'foo'
  using slice = decltype(max(I)); // fails only in clang
                         ^
<source>:2:47: note: default argument declared here
  static constexpr int max(int idx, int min = 0) {
                                              ^

-- 
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/20201118/934e169f/attachment-0001.html>


More information about the llvm-bugs mailing list