language-lawyer

Hiding names with 'using' directive

我们两清 提交于 2021-02-09 11:12:14
问题 Code example: struct A {}; struct B { using A = A; }; int main() { B b; } Clang compiles it. But GCC gives the following error (demo): declaration of 'using A = struct A' changes meaning of 'A' The C++ standard says: If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name ( excluding declarations made visible via using-directives ([basic.lookup.unqual])),

Hiding names with 'using' directive

可紊 提交于 2021-02-09 11:10:20
问题 Code example: struct A {}; struct B { using A = A; }; int main() { B b; } Clang compiles it. But GCC gives the following error (demo): declaration of 'using A = struct A' changes meaning of 'A' The C++ standard says: If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name ( excluding declarations made visible via using-directives ([basic.lookup.unqual])),

Hiding names with 'using' directive

元气小坏坏 提交于 2021-02-09 11:10:13
问题 Code example: struct A {}; struct B { using A = A; }; int main() { B b; } Clang compiles it. But GCC gives the following error (demo): declaration of 'using A = struct A' changes meaning of 'A' The C++ standard says: If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name ( excluding declarations made visible via using-directives ([basic.lookup.unqual])),

Hiding names with 'using' directive

可紊 提交于 2021-02-09 11:09:19
问题 Code example: struct A {}; struct B { using A = A; }; int main() { B b; } Clang compiles it. But GCC gives the following error (demo): declaration of 'using A = struct A' changes meaning of 'A' The C++ standard says: If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name ( excluding declarations made visible via using-directives ([basic.lookup.unqual])),

Hiding names with 'using' directive

假装没事ソ 提交于 2021-02-09 11:09:04
问题 Code example: struct A {}; struct B { using A = A; }; int main() { B b; } Clang compiles it. But GCC gives the following error (demo): declaration of 'using A = struct A' changes meaning of 'A' The C++ standard says: If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name ( excluding declarations made visible via using-directives ([basic.lookup.unqual])),

Can an int be aliased as an unsigned int? [duplicate]

情到浓时终转凉″ 提交于 2021-02-09 11:00:26
问题 This question already has answers here : Writing to a signed integer as if it is unsigned in C++ (2 answers) Efficient way to bit-copy a signed integer to an unsigned integer (4 answers) Closed 3 years ago . Compiler generates code assuming that an int can be aliased by an unsigned int . The folowing code: int f(int& a, unsigned int& b){ a=10; b=12; return a; } int f(int& a, double& b){ a=10; b=12; return a; } generates the folowing assembly, using Clang5 (similar code is produced by GCC or

Can an int be aliased as an unsigned int? [duplicate]

回眸只為那壹抹淺笑 提交于 2021-02-09 10:58:34
问题 This question already has answers here : Writing to a signed integer as if it is unsigned in C++ (2 answers) Efficient way to bit-copy a signed integer to an unsigned integer (4 answers) Closed 3 years ago . Compiler generates code assuming that an int can be aliased by an unsigned int . The folowing code: int f(int& a, unsigned int& b){ a=10; b=12; return a; } int f(int& a, double& b){ a=10; b=12; return a; } generates the folowing assembly, using Clang5 (similar code is produced by GCC or

Can an int be aliased as an unsigned int? [duplicate]

一笑奈何 提交于 2021-02-09 10:58:28
问题 This question already has answers here : Writing to a signed integer as if it is unsigned in C++ (2 answers) Efficient way to bit-copy a signed integer to an unsigned integer (4 answers) Closed 3 years ago . Compiler generates code assuming that an int can be aliased by an unsigned int . The folowing code: int f(int& a, unsigned int& b){ a=10; b=12; return a; } int f(int& a, double& b){ a=10; b=12; return a; } generates the folowing assembly, using Clang5 (similar code is produced by GCC or

Can an int be aliased as an unsigned int? [duplicate]

走远了吗. 提交于 2021-02-09 10:58:09
问题 This question already has answers here : Writing to a signed integer as if it is unsigned in C++ (2 answers) Efficient way to bit-copy a signed integer to an unsigned integer (4 answers) Closed 3 years ago . Compiler generates code assuming that an int can be aliased by an unsigned int . The folowing code: int f(int& a, unsigned int& b){ a=10; b=12; return a; } int f(int& a, double& b){ a=10; b=12; return a; } generates the folowing assembly, using Clang5 (similar code is produced by GCC or

Is a pointer to function (sometimes/always?) a function declarator?

风流意气都作罢 提交于 2021-02-09 05:10:57
问题 (This question has been broken out from the discussion to this answer, which highlights CWG 1892) Some paragraphs of the standard applies specific rules to function declarators ; e.g. [dcl.spec.auto]/3 regarding placeholder types [ emphasis mine]: The placeholder type can appear with a function declarator in the decl-specifier-seq , type-specifier-seq , conversion-function-id , or trailing-return-type , in any context where such a declarator is valid. If the function declarator includes a