Re: Warning when using const pointer to fixed size array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 01.12.2009 00:19, schrieb Aaron Rocha:
I am using :

$ gcc -dumpversion
4.2.4
$ gcc -dumpmachine
x86_64-linux-gnu

As expected, the following code does not generate any warnings when compiling with -Wall:

int main() {

    int number = 0;

    const int * const t =&number;

    return *t;
}

However, this code does:

int main() {

    int array[9] = {0};

    const int (* const p)[9] =&array;


What address are you taking? "array" already stands for the address of the first element (and is hence sort of a pointer). I'm not sure you can take the address of the array name as I think it doesn't have one.

Maybe you want &array[0]?

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux