No, it is not.
&array
is of type pointer to char[SOME_SIZE]
(in the first example given). This means &array + 1
points to memory immediately past the end of array
. Dereferencing that (as in (*(&array+1))
gives undefined behaviour.
No need to analyse further. Once there is any part of an expression that gives undefined behaviour, the whole expression does.
Related Contents:
- Correctly allocating multi-dimensional arrays
- How come an array’s address is equal to its value in C?
- Returning an array using C
- Exceptions to array decaying into a pointer?
- Are negative array indexes allowed in C?
- Are there any non-twos-complement implementations of C?
- Passing a multidimensional variable length array to a function
- Can a const variable be used to declare the size of an array in C?
- How are multi-dimensional arrays formatted in memory?
- Create a pointer to two-dimensional array
- What exactly is the array name in c?
- Why do arrays in C decay to pointers?
- How can mixed data types (int, float, char, etc) be stored in an array?
- Pass an array to a function by value
- Array to pointer decay and passing multidimensional arrays to functions
- Array Type – Rules for assignment/use as function parameter
- Pointer address in a C multidimensional array
- Representation of negative numbers in C?
- How undefined is undefined behavior?
- Do pointers support “array style indexing”?
- reading a text file into an array in c
- How to include a dynamic array INSIDE a struct in C?
- Efficiency: arrays vs pointers
- Why declare a struct that only contains an array in C?
- Manipulate multidimensional array in a function
- Is this a pointer to a pointer of the start of an array?
- Freaky way of allocating two-dimensional array?
- Initializing entire 2D array with one value
- Does &((struct name *)NULL -> b) cause undefined behaviour in C11?
- C – Difference between “char var[]” and “char *var”?
- Why can’t I create an array with size determined by a global variable?
- How to use realloc in a function in C
- Pass a two dimensional array to a function of constant parameter
- How can I find the number of elements in an array?
- “int *nums = {5, 2, 1, 4}” causes a segmentation fault
- How to turn a hex string into an unsigned char array?
- Why “initializer element is not a constant” is… not working anymore?
- Print all permutation in lexicographic order
- Is it guaranteed to be safe to perform memcpy(0,0,0)?
- What’s the difference between array and &array?
- Declaring an array of negative length
- treating memory returned by operator new(sizeof(T) * N) as an array
- Varying string variable in an if condition
- Is int main() { } (without “void”) valid and portable in ISO C?
- C array declaration and assignment?
- dynamic allocating array of arrays in C
- Are non dereferenced iterators past the “one past-the-end” iterator of an array undefined behavior?
- Access struct members as if they are a single array?
- Why is 248×248 the maximum bi dimensional array size I can declare?
- Why can´t we assign a new string to an char array, but to a pointer?