Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[temp.param] Delete outdated wording at p15 #5204

Merged
merged 1 commit into from Jan 15, 2022

Conversation

ChuanqiXu9
Copy link
Contributor

The wording at [temp.param]/15 says:

A template-parameter shall not be given default arguments by two
different declarations if one is reachable from the other.

But it is conflicted with [basic.def.odr]/13:

There can be more than one definition of a
...
default template argument
...
in a program provided that each definition appears in a different
translation unit and the definitions satisfy the [same-meaning
criteria of the ODR].

[temp.param] should be deleted otherwise we couldn't modularize a real
project.

Here is an reduced example:

// templ.h
template<class T = int> class X{}
// foo.cppm
module;
#include "templ.h"
export module foo;
// decls to make 'X' not discard.
//bar.cpp
import foo;
#include "templ.h"

The example above here should be able to be accepted.

The wording at [temp.param]/15 says:
> A template-parameter shall not be given default arguments by two
> different declarations if one is reachable from the other.

But it is conflicted with [basic.def.odr]/13:
> There can be more than one definition of a
> ...
> 	default template argument
> ...
> in a program provided that each definition appears in a different
> translation unit and the definitions satisfy the [same-meaning
> criteria of the ODR].

[temp.param] should be deleted otherwise we couldn't modularize a real
project.
@tkoeppe
Copy link
Contributor

tkoeppe commented Jan 14, 2022

I'd welcome some core feedback on whether this is a) correct and b) really editorial.

@zygoloid
Copy link
Member

zygoloid commented Jan 14, 2022

P1811R0 says this:

Note that this change should apply to all constructs that are permitted to be repeated across translation units but not within a single translation unit, including redeclarations of default arguments and default template arguments in addition to redefinitions of classes, functions, variables, and enumerations.

... which is clear about the intent. The wording there interacts with P1766R1 which made default template arguments be under the control of the ODR, but seemingly failed to strike the (essentially redundant but slightly wrong after P1766R1, and entirely wrong after P1811R0) text in [temp.param]/15 that is the subject of this issue.

Given the history here, and that those two papers both clearly intended to override this pre-existing wording, this seems OK to handle editorially to me.

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's fix this editorially.

@tkoeppe
Copy link
Contributor

tkoeppe commented Jan 15, 2022

OK, thanks everyone, in particular @ChuanqiXu9 for raising this!

@tkoeppe tkoeppe merged commit b345505 into cplusplus:main Jan 15, 2022
ChuanqiXu9 added a commit to llvm/llvm-project that referenced this pull request Jul 8, 2022
…gument across modules

 See cplusplus/draft#5204 for a detailed
 background.

 Simply, the test redundant-template-default-arg.cpp attached to this
 patch should be accepted instead of being complained about the
 redefinition.

 Reviewed By: urnathan, rsmith, ChuanqiXu

 Differential Revision: https://reviews.llvm.org/D118034
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
…gument across modules

 See cplusplus/draft#5204 for a detailed
 background.

 Simply, the test redundant-template-default-arg.cpp attached to this
 patch should be accepted instead of being complained about the
 redefinition.

 Reviewed By: urnathan, rsmith, ChuanqiXu

 Differential Revision: https://reviews.llvm.org/D118034
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants