[llvm-bugs] [Bug 47414] New: Premature substitution into constraints

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 3 17:02:54 PDT 2020


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

            Bug ID: 47414
           Summary: Premature substitution into constraints
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Casey at Carter.net
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Compiling this program:

    template <class, class> constexpr bool is_same_v = false;
    template <class T> constexpr bool is_same_v<T, T> = true;

    template <class T> concept C = is_same_v<T, void>;

    template <class T> requires C<T> using alias = T;

    template <class T> struct S {
        void f() requires C<T> && is_same_v<alias<T>, void> {}
    };

    int main() { S<int>{}; }

with "clang++ -std=c++2a" diagnoses (https://godbolt.org/z/qhhec8):

    <source>:9:41: error: constraints not satisfied for alias template 'alias'
[with T = int]
        void f() requires C<T> && is_same_v<alias<T>, void> {}
                                            ^~~~~~~~
    <source>:12:14: note: in instantiation of template class 'S<int>' requested
here
    int main() { S<int>{}; }
                 ^
    <source>:6:29: note: because 'int' does not satisfy 'C'
    template <class T> requires C<T> using alias = T;
                                ^
    <source>:4:32: note: because 'is_same_v<int, void>' evaluated to false
    template <class T> concept C = is_same_v<T, void>;
                                   ^

Despite that `C<T>` is unsatisfied, the compiler is substituting into the
conjoined `is_same_v<alias<T>, void>` atomic constraint.

-- 
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/20200904/26e2fb88/attachment-0001.html>


More information about the llvm-bugs mailing list