Skip to content

[CWG2091] template parameter lookup differs from g++ wrt. constness #42233

@dommldomml

Description

@dommldomml
mannequin
Bugzilla Link 42888
Version 8.0
OS Linux
Attachments Source code illustrating the problem
CC @DougGregor,@zygoloid

Extended Description

For the attached source file, clang++ errors out with

main.C:18:4: error: invalid operands to binary expression ('AA' and 'S<E, EV>')
        a << x;
        ~ ^  ~
main.C:10:14: note: candidate template ignored: substitution failure [with E = E]: deduced non-type template argument does not have the same type as the corresponding template parameter ('E *' vs 'const E *')
                friend AA& operator<<( AA& os, const S<E,V>& e );

g++ handles the template fine.

Removing the constness of the second operator parameter or adding constness to the variable makes the problem disappear.

In my application a different operatow was chosen leading to a misbehavior.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions