public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2020-04-14 12:41 sinbal2l at gmail dot com
  2020-04-14 12:42 ` [Bug c++/94594] " sinbal2l at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sinbal2l at gmail dot com @ 2020-04-14 12:41 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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
  2020-04-14 12:41 [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 sinbal2l at gmail dot com
@ 2020-04-14 12:42 ` sinbal2l at gmail dot com
  2020-04-14 12:51 ` sinbal2l at gmail dot com
  2020-07-02  8:45 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: sinbal2l at gmail dot com @ 2020-04-14 12:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594

--- Comment #1 from Inbal Levi <sinbal2l at gmail dot com> ---
* declaration

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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
  2020-04-14 12:41 [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 sinbal2l at gmail dot com
  2020-04-14 12:42 ` [Bug c++/94594] " sinbal2l at gmail dot com
@ 2020-04-14 12:51 ` sinbal2l at gmail dot com
  2020-07-02  8:45 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: sinbal2l at gmail dot com @ 2020-04-14 12:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594

--- Comment #2 from Inbal Levi <sinbal2l at gmail dot com> ---
Also, an example with the first struct declaration being in the right form: :)
https://godbolt.org/z/G5rU5h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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
  2020-04-14 12:41 [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 sinbal2l at gmail dot com
  2020-04-14 12:42 ` [Bug c++/94594] " sinbal2l at gmail dot com
  2020-04-14 12:51 ` sinbal2l at gmail dot com
@ 2020-07-02  8:45 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-02  8:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I reported this as PR 65685 a few years ago.

*** This bug has been marked as a duplicate of bug 65685 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-02  8:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 12:41 [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 sinbal2l at gmail dot com
2020-04-14 12:42 ` [Bug c++/94594] " sinbal2l at gmail dot com
2020-04-14 12:51 ` sinbal2l at gmail dot com
2020-07-02  8:45 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).