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

  • Home
  • SEARCH
  • 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 864237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:26:39+00:00 2026-05-15T09:26:39+00:00

I was very surprised when I saw this notation. What does it do and

  • 0

I was very surprised when I saw this notation. What does it do and what kind of C notion is it?

  • 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-05-15T09:26:40+00:00Added an answer on May 15, 2026 at 9:26 am

    This is a compound literal as defined in section 6.5.2.5 of the C99 standard.

    It’s not part of the C++ language, so it’s not surprising that C++ compilers don’t compile it. (or Java or Ada compilers for that matter)

    The value of the compound literal is that of an unnamed object initialized by the
    initializer list. If the compound literal occurs outside the body of a function, the object
    has static storage duration; otherwise, it has automatic storage duration associated with
    the enclosing block.

    So no, it won’t destroy the stack. The compiler allocates storage for the object.

    Parenthesis are put around the type and it is then followed by an initializer list – it’s not a cast, as a bare initialiser list has no meaning in C99 syntax; instead, it is a postfix operator applied to a type which yields an object of the given type. You are not creating { 0, 3 } and casting it to an array, you’re initialising an int[2] with the values 0 and 3.


    As to why it’s used, I can’t see a good reason for it in your single line, although it might be that a could be reassigned to point at some other array, and so it’s a shorter way of doing the first two lines of:

    int default_a[] = { 0, 2 };
    int *a = default_a;
    
    if (some_test) a = get_another_array();
    

    I’ve found it useful for passing temporary unions to functions

    // fills an array of unions with a value
    kin_array_fill ( array, ( kin_variant_t ) { .ref = value } )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very surprised this issue hasn't been discussed in-depth: This article tells us how
This morning I accidentally saw the following snippet code, I was fairly surprised because
I was very surprised that I couldn't find this answer on Google. I have
I was very surprised to get this error today, as it's one that I've
I was very surprised to get this error today, as it's one that I've
I'm very surprised of this superior site! My Goal is to get a .txt-file,
I'm very surprised not to be able to open my Xcode project on another
I am pretty new to silverlight and was very surprised to see that only
Very simple + silly question: Does clojure provide multi maps? I currently have something
Very new to python and can't understand why this isn't working. I have a

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.