This is the mail archive of the
mailing list for the GCC project.
Re: pass bounded array as unbounded
- From: Ian Lance Taylor <iant at google dot com>
- To: Daniel Bengtsson <Danesh dot D at bredband dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: 03 Oct 2007 17:34:10 -0700
- Subject: Re: pass bounded array as unbounded
- References: <email@example.com>
Daniel Bengtsson <Danesh.D@bredband.net> writes:
> I have a already written code in C which should be compiled using GCC. In
> this code there is an 4x3 array which will be passed to a function as
> unbounded array:
> int arr
> myFunc (int myArray)
> int temp=myArray
> In this function, values out of boundaries of input array is used (like the
> code above). Now I have these questions:
> 1. Why I get no error when values out of boundary is used?
> 2. I have checked that for example value of the element  always has
> same value! I expected at least that this contain random value while it is
> not allocated before. Does GCC fill it with something else or it depends to
> value of other elements in array?
This question is not appropriate for firstname.lastname@example.org; the gcc mailing
list is for developers of gcc. You could try the email@example.com
mailing list. Please send any followups to some other mailing list.
This is not really a gcc question at all. It is a question about how
1) Inside myFunc there is no information about how long the array is,
so there is no error from referring to an out of bounds element.
2) The value is effectively random. That doesn't mean that you won't
always get the same value. It means that it is unpredictable what
will happen. In practice it depends on the the values of other
global variables in the program.