Информация об изменениях

Сообщение Re[3]: Почему clang не компилирует этот код в отличии от gcc от 20.03.2023 21:51

Изменено 20.03.2023 21:56 rg45

Re[3]: Почему clang не компилирует этот код в отличии от gcc
Здравствуйте, σ, Вы писали:

R>>не является объектом с внешним связыванием


σ>Связывание — это вроде про имена, а не объекты.


Да, с этим не поспоришь, конечно. Но, в то же время, сам стандрат достаточно длительный промежуток времени использовал термин linkage применительно именно к объектам, а не к именам.

C++11
14.3.2 Template non-type arguments [temp.arg.nontype]
1 A template-argument for a non-type, non-template template-parameter shall be one of:
— an integral constant-expression of integral or enumeration type; or
— the name of a non-type template-parameter; or
— the address of an object or function with external linkage, including function templates and function
template-ids but excluding non-static class members, expressed as & id-expression where the & is
optional if the name refers to a function or array, or if the corresponding template-parameter is a reference;
or
— a pointer to member expressed as described in 5.3.1 .


Начиная с 14-го, разрешили использование объектово с internal linkage, но связка linkage и object все еще сохраняется:

C++11
14.3.2 Template non-type arguments [temp.arg.nontype]
1 A template-argument for a non-type, non-template template-parameter shall be one of:
— for a non-type template-parameter of integral or enumeration type, a converted constant expression
(5.19) of the type of the template-parameter; or
— the name of a non-type template-parameter; or
— a constant expression (5.19) that designates the address of a complete object with static storage duration
and external or internal linkage
or a function with external or internal linkage, including function
templates and function template-ids but excluding non-static class members, expressed (ignoring parentheses)
as & id-expression, where the id-expression is the name of an object or function, except that the
& may be omitted if the name refers to a function or array and shall be omitted if the corresponding
template-parameter is a reference; or


Начиная с 17-го упоминание о linkage уже нет. В 20-м переписали все еще больше. Так что, мои воспоминания о linkage в этом контексте вообще можно отнести к фантомным болям
Re[3]: Почему clang не компилирует этот код в отличии от gcc
Здравствуйте, σ, Вы писали:

R>>не является объектом с внешним связыванием


σ>Связывание — это вроде про имена, а не объекты.


Да, с этим не поспоришь, конечно. Но, в то же время, сам стандрат достаточно длительный промежуток времени использовал термин linkage применительно именно к объектам, а не к именам.

C++11
14.3.2 Template non-type arguments [temp.arg.nontype]
1 A template-argument for a non-type, non-template template-parameter shall be one of:
— an integral constant-expression of integral or enumeration type; or
— the name of a non-type template-parameter; or
— the address of an object or function with external linkage, including function templates and function
template-ids but excluding non-static class members, expressed as & id-expression where the & is
optional if the name refers to a function or array, or if the corresponding template-parameter is a reference;
or
— a pointer to member expressed as described in 5.3.1 .


Начиная с 14-го, разрешили использование объектов с internal linkage, но связка linkage и object все еще сохраняется:

C++14
14.3.2 Template non-type arguments [temp.arg.nontype]
1 A template-argument for a non-type, non-template template-parameter shall be one of:
— for a non-type template-parameter of integral or enumeration type, a converted constant expression
(5.19) of the type of the template-parameter; or
— the name of a non-type template-parameter; or
— a constant expression (5.19) that designates the address of a complete object with static storage duration
and external or internal linkage
or a function with external or internal linkage, including function
templates and function template-ids but excluding non-static class members, expressed (ignoring parentheses)
as & id-expression, where the id-expression is the name of an object or function, except that the
& may be omitted if the name refers to a function or array and shall be omitted if the corresponding
template-parameter is a reference; or


Начиная с 17-го упоминания о linkage уже нет. В 20-м переписали все еще больше. Так что, мои воспоминания о linkage в этом контексте вообще можно отнести к фантомным болям