public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sinbal2l at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [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
Date: Sun, 12 Apr 2020 20:34:24 +0000	[thread overview]
Message-ID: <bug-94569-4@http.gcc.gnu.org/bugzilla/> (raw)

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!

             reply	other threads:[~2020-04-12 20:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12 20:34 sinbal2l at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94569-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).