[Developers] Const correctness for cGH *

Thomas Radke tradke at aei.mpg.de
Tue Jun 7 07:29:49 CDT 2005


Erik Schnetter wrote:
> You have to use an explicit case.  In the example below,
> 
> void sub (const int * pci)
> {
>   int * pi1 = pci;
>   int * pi2 = (int *) pci;
>   ++ * pi1;
>   ++ * pi2;
> }
> 
> pi1 is set without an explicit cast and leads to the warning.  pi2 gives 
> no warning (with both gcc and Intel).

Interesting. Before I didn't create an intermediate non-const pointer 
but was doing the type case inline. Don't know why gcc treats this as 
different things.
Anyway, making the cctkGH argument a const pointer seems okay, we don't 
even need a special compiler warn flag for gcc.


-- 
Cheers, Thomas.



More information about the Developers mailing list