Skip to content

Concepts with parameter pack not at end silently ignores errors when used #48182

Closed
@MitalAshok

Description

@MitalAshok
Bugzilla Link 48838
Version trunk
OS All
Attachments Patch to reject concepts with parameter packs not at the end
CC @zygoloid

Extended Description

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:

// A non-expanded parameter pack before the end of the parameter list
// only occurs for an ill-formed template parameter list, unless we've
// got a partial argument list for a function template, so just bail out.
if (Param + 1 != ParamEnd)
return true;
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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions