[llvm-bugs] [Bug 48838] New: Concepts with parameter pack not at end silently ignores errors when used

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 21 14:16:58 PST 2021


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

            Bug ID: 48838
           Summary: Concepts with parameter pack not at end silently
                    ignores errors when used
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mital.vaja at googlemail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 24407
  --> https://bugs.llvm.org/attachment.cgi?id=24407&action=edit
Patch to reject concepts with parameter packs not at the end

There are no errors or warnings compiling the following with `clang++
-std=c++20 -fsyntax-only`:

    template<typename, typename..., typename = int>
    concept invalid = true;

    template<typename> requires invalid<int>
    no errors are printed
    ;

    static_assert(invalid<int> also here ;

    int main() {
        bool b;
        b = invalid<int> not just in declarations;
        return b;
    }


This happens because this assumption is violated with concepts:
https://github.com/llvm/llvm-project/blob/39239f9b5666bebb059fa562badeffb9f1c3afab/clang/lib/Sema/SemaTemplate.cpp#L5756-L5760
and no diagnosis is printed beforehand

I have attached a patch that makes concepts like `invalid` which have a
parameter pack not at the end an error.

There is currently no wording in the standard that makes these concepts
ill-formed (The current C++20 [temp.param]p14 only mentions "primary class
template, primary variable template, or alias template"), but I think this is
an oversight.

-- 
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/20210121/905a8167/attachment.html>


More information about the llvm-bugs mailing list