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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:16:26+00:00 2026-06-03T02:16:26+00:00

Generally we declare the array in following format: DataType array_name[SIZE]; SO If I tried

  • 0

Generally we declare the array in following format:

DataType array_name[SIZE];

SO If I tried creating 0 length array for e.g.

int arr[0]; //Line#1
arr[0] = 5; //Line#2

I do not get any error when above code is executed.In this case is memory allocated for single integer?

  • 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-03T02:16:29+00:00Added an answer on June 3, 2026 at 2:16 am

    Why does the Line#1 not generate any compilation error?
    Ideally, it should!
    It is not legal code to create an array of size 0 on local storage.
    Ideally, the compiler should issue you an error, probably some compiler extension allows this to compile but as per the standard this is not a valid code.Try compiling with -pedantic.

    Reference:

    C++03 Standard 8.3.4/1:

    If the _constant-expression+ (5.19) is present, it shall be an integral constant expression and its value shall be greater than zero.

    Further,
    Why does the Line#2 not generate any compilation error?
    Because writing beyond the bounds of an allocated array is Undefined Behavior. An Undefined Behavior does not need the compiler to provide you any diagnostic. Note that once the code exhibits an Undefined Behavior literally anything can happen and all bets are off.

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

Sidebar

Related Questions

Generally, when you specify a function the scale/precision/size of the return datatype is undefined.
In simplicity, PL/SQL generally follow the following: DECLARE Variable declaration BEGIN Program Execution EXCEPTION
Every class that wants to use java.util.logging generally needs to declare a logger like
Generally, when using the conditional operator, here's the syntax: int x = 6; int
As some of you will know, it is generally not possible to mock a
declare @t int set @t = 10 if (o = 'mmm') set @t =
I have 2 doubts regarding basics of pointers usage. With the following code int
NumberFormat JavaDoc says: Number formats are generally not synchronized. It is recommended to create
Generally when I use ClickOnce when I build a VB.NET program but it has
Generally the database server is the biggest, most expensive box we have to buy

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.