[Bug c++/94569] alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 --- Comment #10 from Inbal Levi --- Actually, you're right about the origin being [dcl.align]p5 here too, though the test cases are different. Thanks.
[Bug c++/94569] alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 --- Comment #8 from Inbal Levi --- See here: https://bugs.llvm.org/show_bug.cgi?id=45890
[Bug c++/94569] alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 --- Comment #7 from Inbal Levi --- Not exactly. 94594 is talking about object's members impose their alignment on the object's type, whether this bug is talking about object type imposes its alignment on every object of that type (notice that in the example here, unlike the one on 94594, there's no alignment of the members). (this restriction is located at: [basic.align/1] [...] An object type imposes an alignment requirement on every object of that type; stricter alignment can be requested using the alignment specifier. as posted below in the comments, unfortunately, since I couldn't edit the bug) (Though, since posting that bug, I realized that though the restriction should hold, the querying part, which is alignof(object), should first be qualified in the standard. There's a paper: P2152 :) )
[Bug c++/95094] alignof(reference_to_type) doesn't return alignof(referenced_type) as it should by the standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95094 --- Comment #3 from Inbal Levi --- Actually, you are right, I'm currently working on a paper to change it, should have waited for afterward. The reason to change it is to align (...) with C behavior.
[Bug c++/95094] New: alignof(reference_to_type) doesn't return alignof(referenced_type) as it ought to, by the standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95094 Bug ID: 95094 Summary: alignof(reference_to_type) doesn't return alignof(referenced_type) as it ought to, by the standard Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sinbal2l at gmail dot com Target Milestone: --- >From the C++ standard: 7.6.2.5 Alignof [expr.alignof]p3 3 When alignof is applied to a reference type, the result is the alignment of the *referenced* type. IINM, in the latest version, the returned value is of the reference itself: #include int main() { alignas(32) double d; double _d = d; printf("Alignment of d: %d\n", alignof(d)); // 32 printf("Alignment of ref_d: %d\n", alignof(ref_d)); // 8 } https://godbolt.org/z/S9UJUv P.S. thank you very much for doing such a great job! (3) (94594)
[Bug c++/94569] alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 --- Comment #5 from Inbal Levi --- Stumbled across another rule which might be relevant here is: [basic.align/1] [...] An object type imposes an alignment requirement on every object of that type; stricter alignment can be requested using the alignment specifier (9.12.2). Inherited from the C standard, which results in an error for the following code: #include typedef struct U U; struct U { } __attribute__((aligned (32))); int main() { _Alignas(16) U my_u; // alignas(obj) of a weaker alignment than the type. } https://godbolt.org/z/tdEJgo
[Bug c++/94594] struct containing an aligned obj with stronger alignment, change the alignment accordingly instead of throwing an error, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594 --- Comment #2 from Inbal Levi --- Also, an example with the first struct declaration being in the right form: :) https://godbolt.org/z/G5rU5h
[Bug c++/94594] struct containing an aligned obj with stronger alignment, change the alignment accordingly instead of throwing an error, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594 --- Comment #1 from Inbal Levi --- * declaration
[Bug c++/94594] New: struct containing an aligned obj with stronger alignment, change the alignment accordingly instead of throwing an error, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594 Bug ID: 94594 Summary: struct containing an aligned obj with stronger alignment, change the alignment accordingly instead of throwing an error, inconsistent with the C++ standard Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sinbal2l at gmail dot com Target Milestone: --- This example actually coming straight from the standard. >From the standard (with the first example being part of the quote): [dcl.align]p5 "The combined effect of all alignment-specifiers in a declaration shall not specify an alignment that is less strict then the alignment that would be required for the entity being declared if all alignment-specifiers appertaining to that entity were omitted. [Example: struct alignas(8) S {}; struct alignas(1) U { S s; }; // error: U specifies an alignment that is less strict than if the alignas(1) were omitted. (*) — end example] " (*) (My) Meta comment: If I'm not mistaken, this should be alignas(8) But on the latest revision, this compiles, aligning my_u to 8. typedef struct alignas(8) S{}; typedef struct alignas(1) { // This decleration should not be allowed S i; }U; int main() { U my_u; cout << "alignof (decltype(my_u))" << alignof (decltype(my_u)) << endl; } https://godbolt.org/z/KvMo4A Attaching the related (but not same, IMO) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 (Hopefully, I quoted the right part this time...) P.S. Thank you very much for doing such a great job! (No. 2)
[Bug c++/94569] alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 --- Comment #2 from Inbal Levi --- Yes, you're probably right, got the wrong one. Thanks!
[Bug c++/94569] New: alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 Bug ID: 94569 Summary: alignas(object) with a weaker (smaller) alignment than the alignas(type) of it's type compiles, inconsistent with the C++ standard Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sinbal2l at gmail dot com Target Milestone: --- The standard specifies: >From the standard: [9.12.2 Alignment specifier, section 6, pg 226] If the defining declaration of an entity has an alignment-specifier, any non-defining declaration of that entity shall either specify equivalent alignment or have no alignment-specifier. Conversely, if any declaration of an entity has an alignment-specifier, every defining declaration of that entity shall specify an equivalent alignment. But on the latest revision, this compiles: typedef struct alignas(32){ int i; }U; int main() { alignas(16) U my_u; // alignas(obj) of a weaker alignment than the type. cout << "alignof(my_u): " << alignof(my_u) << endl; cout << "alignof (decltype(my_u))" << alignof (decltype(my_u)) << endl; } https://godbolt.org/z/2uNAag P.S. thank you very much for doing such a great job!