c99 - In C, if this isn't an address constant, what is it? -
what, exactly, numbers
in following declaration, if not address constant?
int main() { int numbers[3] = {1,2,3}; return 0; }
disassembling program shows 1, 2, , 3 dynamically placed on local stack space, rather whole array being treated constant. hence, {1,2,3}
not have static storage duration, numbers
not address constant, per c99 spec.
c99, section 6.6.9: "an address constant null pointer, pointer lvalue designating object of static storage duration, or pointer function designator..."
however, adding line numbers++
after declaration causes following compile error in gcc 4.1.2:
error: invalid lvalue in increment
so constant, isn't address constant. know official name of type of constant in c99 (or similar)?
numbers
non-constant, automatic, array variable of function main
.
because automatic , non-constant can not have static storage.
because array variable (and not you'll notice pointer) can not incremented.
note can do
int main() { int numbers[3] = {1,2,3}; int *n = numbers+1; n++; return 0; }
Comments
Post a Comment