Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:39:38+00:00 2026-06-04T04:39:38+00:00

I was wondering about the following: is the new _Alignas alignment specifier in C11

  • 0

I was wondering about the following: is the new _Alignas alignment
specifier in C11 applicable to structure members?

I’ve always assumed that much, but a thorough reading of the N1570
public draft seems to indicate that an alignment-specifier cannot
appear in a specifier-qualifier-list, which is where I’d expect it
to be, if it were supported. I’ve read the grammar a couple of times
but can’t figure out how _Alignas is supposed to be permitted in
a structure member declaration.

However, it seems to me that the intent of the standard is that
_Alignas should be applicable to structure members as the paragraph
on _Alignas (§ 6.7.5) states that “an alignment attribute shall not
be specified in a declaration of […] a bit-field”. Given that
the term “bit-field” is defined in § 6.7.2.1 to be a structure
member (precise wording: “such a member is called a bit-field“),
I had always interpreted that sentence to implicitly mean alignment
specifiers were allowed for non-bit-field members.

Checking against existing implementations shows that both Clang 3.0
and GCC 4.7 support _Alignas on structure members without
complaining (with -pedantic). The Clang source code reproduces the
same grammar from N1570, except Parser::ParseSpecifierQualifierList
allows alignment specifiers; the function does contain a TODO element,
though, that reads:

/// TODO: diagnose attribute-specifiers and alignment-specifiers.

The GCC C parser code appears to be similar, i.e. even though it quotes
the standard grammar, it allows alignment specifiers in
specifier-qualifier lists.

I’ve also checked the list of known defects, as well as comp.lang.c
and comp.std.c, to see if the topic had been raised there but it
doesn’t appear to be the case. Hence, my question: are alignment
specifiers supposed to be allowed on structure members?

EDIT: The relevant grammar rules are:

// Compare this...
(6.7) declaration-specifiers:
           storage-class-specifier declaration-specifiers_opt
           type-specifier declaration-specifiers_opt
           type-qualifier declaration-specifiers_opt
           function-specifier declaration-specifiers_opt
           // This seems to be the only place that mentions
           // alignment-specifier on the rhs of a rule.
           alignment-specifier declaration-specifiers_opt

(6.7.2.1) struct-or-union-specifier:
           struct-or-union identifier_opt { struct-declaration-list }
           struct-or-union identifier

(6.7.2.1) struct-declaration-list:
           struct-declaration
           struct-declaration-list struct-declaration

(6.7.2.1) struct-declaration:
           specifier-qualifier-list struct-declarator-list_opt ;
           static_assert-declaration

// ...to this.
(6.7.2.1) specifier-qualifier-list:
           type-specifier specifier-qualifier-list_opt
           type-qualifier specifier-qualifier-list_opt
           // Missing alignment-specifier specifier-qualifier-list_opt?

(6.7.5) alignment-specifier:
          _Alignas ( type-name )
          _Alignas ( constant-expression )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:39:39+00:00Added an answer on June 4, 2026 at 4:39 am

    Section 6.7.5, p 6, clearly specifies that this also concerns alignment of members

    The alignment requirement of the declared object or member is taken to
    be the specified alignment.

    So the intended semantic is that one. If as you say the formal specification of the grammar misses that bit (I didn’t check), this is a defect, and you should report it.

    Edit: Looking into the grammar, it seems to me that an addition of alignment-specifier in 6.7.2.1 is missing in the cases of specifier-qualifier-list, and also that a textual explanation in para 14 would be in order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering about the following fact. I have a data repository that returns
I'm quite new to iOs Programming.. At the moment I'm wondering about following issue.
I have been wondering about the following lines of code [self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
I'm wondering how i would go about making the following application: a user signs
Following on from my other post about primary keys I am wondering if there
I'm new to PDO and PHP, I'm wondering how I would go about defining
I am wondering about javascript prototype. I know that prototyping enables the user to
The question's title may sound stupid, but I have beenw wondering about the following
I'm new to MongoDB and was wondering about querying for domain objects with registered
I'm playing around with LINQ and related subjects and was wondering about the following.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.