cplusplus / cplusplus/draft

we didn't explicitly specify that the current instantiation does not cause an implicit instantiation

Open
#5,289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[temp.inst] p16

There is an implementation-defined quantity that specifies the limit on the total depth of recursive instantiations ([implimits]), which could involve more than one template. The result of an infinite recursion in instantiation is undefined.

has an example that:

template<class T> class X {
  X<T>* p;    // #1      // OK
  X<T*> a;    // #2      // implicit generation of X<T> requires
                    // the implicit instantiation of X<T*> which requires
                    // the implicit instantiation of X<T**> which …

  // an extra example
  explicit(sizeof(X<T>)>1) operator int(){  // #3
      return 0;
  }
};

In either case of the three, the injected-class-name X is used as a template-name as per [temp.local] p1. That means, all the use of X can be replaced by ::X. [temp.inst] p2 states that

Unless a class template specialization is a declared specialization, the class template specialization is implicitly instantiated when the specialization is referenced in a context that requires a completely-defined object type or when the completeness of the class type affects the semantics of the program.

The operand of sizeof requires the operand to have a completely-defined object type and the class template specialization X<T> is not a declared specialization, thus, that operand should cause the implicit instantiation of X<T>, the implicit instantiation for X<T>, in turn, causes the implicit instantiation of explicit(sizeof(X<T>)>1) , which process is recursive.

We do not have a sufficient reason that can interpret why the current instantiation won't cause that non-reasonable instantiation that would violate [temp.inst] p16.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading [temp.inst] paragraphs 2 and 16 alongside [temp.local] paragraph 1 and the referenced [implimits] wording. Determine how the current-instantiation example interacts with implicit instantiation, then clarify the draft so the intended non-recursive behavior is explicit and the interpretation is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.