[llvm-bugs] [Bug 49998] New: templated constexpr variable fails to deduce auto type in template context

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 16 08:22:38 PDT 2021


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

            Bug ID: 49998
           Summary: templated constexpr variable fails to deduce auto type
                    in template context
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pro.guillaume.dua 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

Using clang 12.0.0

Note : Maybe in correlation with https://bugs.llvm.org/show_bug.cgi?id=43459

Looks like Clang cannot evaluate an `auto` type for a constexpr
template-variable which depends on another,  
when both depends on a template context.

See live example here on godbolt : https://godbolt.org/z/ofveeGoWe

```cpp
template <typename ... Ts>
struct foo
{
    constexpr inline static auto value = 42;
};

template <typename ... Ts>
struct bar
{
    template <typename U>
    constexpr static inline auto foo_value = foo<Ts...>::value; // KO
    // nb : replacing `auto` with `int` remove the error
};

static_assert(bar<int>::foo_value<int> == 42);
```

Which results in :

```log
<source>:15:40: error: invalid operands to binary expression ('const auto' and
'int')
```

Stackoverflow associated post :
https://stackoverflow.com/questions/67127710/clang-invalid-operands-to-binary-expression-const-auto-and-int-with-cons

-- 
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/20210416/d36346ce/attachment.html>


More information about the llvm-bugs mailing list