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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:33+00:00 2026-05-28T05:39:33+00:00

This answer of mine generated some comments claiming that the following construct is not

  • 0

This answer of mine generated some comments claiming that the following construct is not legal C/C++:

void f (int* a) ;
f ((int[]){1,2,3,4,0}) ;

(see this ideone link for a full program). But we weren’t able to resolve the issue. Can anybody shed any light on this? What do the various standards have to say?

  • 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-28T05:39:34+00:00Added an answer on May 28, 2026 at 5:39 am

    It’s valid C99 as far as I can tell – that’s passing a compound literal.

    The C99 standard has this as an example (§6.5.2.5/9):

    EXAMPLE 1 The file scope definition

    int *p = (int []){2, 4};
    

    initializes p to point to the first element of an array of two ints, the first having the value two and the second, four. The expressions in this compound literal are required to be constant. The unnamed object has static storage duration.

    Note that the (int []) thing is not a cast here.

    This is not a valid C++ construct though, compound literals are not part of the C++ standard (C++11 included). Some compilers allow it as an extension. (GCC does, pass -Wall -pedantic to get a diagnostics about it. IBM xlC allows it as an extension too.)

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

Sidebar

Related Questions

This came up from this answer to a previous question of mine . Is
This answer says that Linq is targeted at a slightly different group of developers
This answer to a question about C++ unit test frameworks suggests a possibility that
In this answer to this question , Lachlan-Hunt writes the following: With HTML5, you
in this answer he said that i can use RIA services while creating my
I am referencing this answer (emphasis mine): Have a look at the ContractClass and
Several comments on a recent answer of mine, What other useful casts can be
There are some similar questions but not exactly like mine. Is there a Func
I've seen some similar questions to mine here, but they don't really answer me...
This question arose when an anonymous user downvoted an answer of mine involving KeyListeners

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.