public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2020-04-12 20:34 sinbal2l at gmail dot com
  2020-04-13  1:25 ` [Bug c++/94569] " richard-gccbugzilla at metafoo dot co.uk
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: sinbal2l at gmail dot com @ 2020-04-12 20:34 UTC (permalink / raw)
  To: gcc-bugs

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!

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 20:34 [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 sinbal2l at gmail dot com
2020-04-13  1:25 ` [Bug c++/94569] " richard-gccbugzilla at metafoo dot co.uk
2020-04-13  2:19 ` sinbal2l at gmail dot com
2020-04-14  7:00 ` rguenth at gcc dot gnu.org
2020-04-14  7:32 ` richard-gccbugzilla at metafoo dot co.uk
2020-04-14 10:46 ` redi at gcc dot gnu.org
2020-05-10  6:29 ` sinbal2l at gmail dot com
2020-07-02  8:47 ` redi at gcc dot gnu.org
2020-07-02 10:25 ` sinbal2l at gmail dot com
2020-07-02 10:33 ` sinbal2l at gmail dot com
2020-07-02 13:06 ` redi at gcc dot gnu.org
2020-07-02 14:35 ` sinbal2l at gmail dot com

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).