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 8954299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:17:35+00:00 2026-06-15T14:17:35+00:00

I didn’t know this before, but it turns out that: [C++11: 3.7.5]: The storage

  • 0

I didn’t know this before, but it turns out that:

[C++11: 3.7.5]: The storage duration of member subobjects, base class subobjects and array elements is that of their complete object (1.8).

That means that x->a in the example below has dynamic storage duration.

I’m wondering whether there are any elsewhere-defined semantics that make reference to storage duration that imbue member a with different behaviour between object *x and y? An example would be the rules governing object lifetime.

struct T
{
   int a;
};

int main()
{
   std::unique_ptr<T> x(new T);
   T y;
}

And how about if T were non-POD (and other kinds of UDTs)?

In short, my lizard brain expects any declaration looking like int a; to have automatic (or static) storage duration, and I wonder whether any standard wording accidentally expects this too.


Update:

Here’s an example:

[C++11: 3.7.4.3/4]: [..] Alternatively, an implementation may have strict pointer safety, in which case a pointer value that is not a safely-derived pointer value is an invalid pointer value unless the referenced complete object is of dynamic storage duration [..]

On the surface of it, I wouldn’t expect the semantics to differ between my x->a and my y.a, but it’s clear that there are areas, that are not obviously related to object lifetime, where they do.

I’m also concerned about lambda capture rules, which explicitly state “with automatic storage duration” in a number of places, e.g.:

[C++11: 5.1.2/11]: If a lambda-expression has an associated capture-default and its compound-statement odr-uses (3.2) this or a variable with automatic storage duration [..]

[C++11: 5.1.2/18]: Every occurrence of decltype((x)) where x is a possibly parenthesized id-expression that names an entity of automatic storage duration is treated as if x were transformed into an access to a corresponding data member of the closure type that would have been declared if x were an odr-use of the denoted entity.

and others.

  • 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-15T14:17:37+00:00Added an answer on June 15, 2026 at 2:17 pm

    No. This storage duration inheritance is what makes subobjects work. Doing anything else would simply be quite impossible. Else, you could not design any type that could be allocated both statically and dynamically.

    Simply put, any violation of this rule would simply break everything.

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

Sidebar

Related Questions

I didn't expect this is that complex. But I can't figure out how I
I didn't face this error before. I have a database db , that contains
Didn't know how else to put this. Say I have a JavaScript method that
Didn't even know how to exactly phrase this question, but here is the the
I didn't really know how to formulate the title. But this is my problem.
I didn't find an answer to this question because I don't know if I'm
I didn't use NGen before but now I need to improve startup performance of
I didn't design this table, and I would redesign it if I could, but
Didn't really know how to title this. First time writing a gem so not
(Didn't mean to create a new question, but revised the old one enough that

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.