Skip to content

[section.label] Clarify how class rule has to be applied to class templates so that IFNDR can be distinguished from IF for template instantiations #877

@ranaanoop

Description

@ranaanoop

Full name of submitter: Anoop Rana

Reference (section label): [class.copy.ctor]

Issue description: Consider the following code that used to compile with clang but not with gcc and msvc: Demo

template<typename T>
struct C {
    C() {}
    C(C<bool>);  
};
C<bool> c;    //compiles with clang but not with gcc and msvc

We do have [class.copy.ctor] that seems to make it ill-formed:

A declaration of a constructor for a class X is ill-formed if its first parameter is of type cv X and either there
are no other parameters or else all other parameters have default arguments

Note that there is also [temp.res](temp.res#5 in particular) dealing with template instantiations. Now, either the rule from [class.copy.ctor] doesn't apply and the program is well-formed or it does apply to the instantiation and then it is ill-formed and the only question is whether it is IFNDR. I think it is more likely not to apply interpreting the exact wording, although it is probably intended to apply. I guess one could argue that technically a hypothetical instantiation of A<bool> would be ill-formed in the latter case due to a non-dependent construct, so that it is IFNDR. But that wouldn't really be intended I would say. [temp.res]/5 doesn't seem well-worded to me for this particular case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions