Improve [dcl.fct.def.general] p2
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[dcl.fct.def.general] p2
The type of a parameter or the return type for a function definition shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body unless the function is deleted ([dcl.fct.def.delete]).
Consider these examples
Example 1:
struct C;
template<class T>
struct D{
auto show(){
return reinterpret_cast<C&&>((int&&)0); // ignore the UB here
}
};
Example 2:
struct C;
struct D{
template<class T>
T show(){
return reinterpret_cast<C&&>((int&&)0); // ignore the UB here
}
};
Example 3:
struct C;
struct D{
template<class T>
C show(){
return T{};
}
};
Example 4:
struct C;
struct D{
auto show(){
return reinterpret_cast<C&&>((int&&)0); // ignore the UB here
}
};
The first two examples are accepted by both GCC and Clang. Conversely, the last two are rejected by both of them. It seems [dcl.fct.def.general] p2 didn't cover the templated entity case where the return type or parameter types are placeholder types or dependent types. The modification is that:
If the function definition is not for a templated function:
- the type of a parameter or the return type(possibly deduced from placeholder type deduction) shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body unless the function is deleted.
Otherwise
if the type is a placeholder type or a dependent type:
- the type shall not be a (possibly cv-qualified) class type that is incomplete or abstract at the point of instantiation unless the function is deleted.
Otherwise
- the type shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body at the definition context unless the function is deleted.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with [dcl.fct.def.general] paragraph 2 and compare the four examples against the stated GCC and Clang behavior. Review the proposed distinction between templated and non-templated functions, including definition context and point of instantiation; done means the standard wording clearly covers all examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100