With Xcode 7 I have a new warning using vImageHistogramSpecification_ARGB8888().
Reduced:
----------------------------------
#include <Accelerate/Accelerate.h>
int main (void)
{
vImagePixelCount histAlphaBuffer[256];
vImagePixelCount histRedBuffer[256];
vImagePixelCount histGreenBuffer[256];
vImagePixelCount histBlueBuffer[256];
vImagePixelCount* histBuffer[4] = {
histAlphaBuffer, histRedBuffer,
histGreenBuffer, histBlueBuffer};
vImageHistogramCalculation_ARGB8888(
NULL, histBuffer, kvImageNoFlags);
vImageHistogramSpecification_ARGB8888(
NULL, NULL, histBuffer, kvImageNoFlags);
return 0;
}
----------------------------------
test.c:18:16: warning: passing 'vImagePixelCount *[4]' to parameter of type 'const vImagePixelCount **' (aka 'const unsigned long **') discards qualifiers in nested
pointer types [-Wincompatible-pointer-types-discards-qualifiers]
NULL, NULL, histBuffer, kvImageNoFlags);
^~~~~~~~~~
Is it just me or does the declaration of vImageHistogramSpecification_ARGB8888() itself not have its consts right?
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng se...@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list (PerfOptimi...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/perfoptimization-dev/perfoptimization-dev-garchive-8409%40googlegroups.com
This email sent to perfoptimization-...@googlegroups.com
With Xcode 7 I have a new warning using vImageHistogramSpecification_ARGB8888().
…
test.c:18:16: warning: passing 'vImagePixelCount *[4]' to parameter of type 'const vImagePixelCount **' (aka 'const unsigned long **') discards qualifiers in nested
pointer types [-Wincompatible-pointer-types-discards-qualifiers]
NULL, NULL, histBuffer, kvImageNoFlags);
^~~~~~~~~~
void foo(const int **p){static const int Two = 2;p[0] = &Two; // Legal, assigns const int * to const int *.}void bar(void){int *xfoo(&x);x[0] = 3; // Overtly legal, assigns int to int. But computer attempts to put 3 into constant Two!}
Is it just me or does the declaration of vImageHistogramSpecification_ARGB8888() itself not have its consts right?
>On Jul 2, 2015, at 09:43, Sean McBride <se...@rogue-research.com> wrote:
>
>> With Xcode 7 I have a new warning using
>vImageHistogramSpecification_ARGB8888().
>> …
>> test.c:18:16: warning: passing 'vImagePixelCount *[4]' to parameter of
>type 'const vImagePixelCount **' (aka 'const unsigned long **') discards
>qualifiers in nested
>> pointer types [-Wincompatible-pointer-types-discards-qualifiers]
>> NULL, NULL, histBuffer, kvImageNoFlags);
>> ^~~~~~~~~~
>
>I am unsure why you see this newly in Xcode 7. I see the same error
>(with a less detailed message) in Snow Leopard, using gcc 4.2.1. Are you
>sure this code compiled without warning previously?
First, thanks for your reply.
Quite sure. I have 10.6 to 10.10 buildbots that have no such warnings. But...
>Since we know vImageHistogramSpecification_ARGB8888 is well behaved, it
>is safe to ignore this warning
Yeah, I figured, but thanks for confirming.
>, and you may avoid it by casting the
>argument to “const vImagePixelCount **” in the function call. It is a
>shortcoming of C that there is not a better way to do this.
So actually I already have that cast there, which is no doubt why my bots don't show any warnings. New in Xcode 7 is the fact that even *with* that cast I get a warning:
/Users/sean/Desktop/test.c:18:43: warning: cast from 'vImagePixelCount **' (aka 'unsigned long **') to 'const vImagePixelCount **' (aka 'const unsigned long **') must have all intermediate
pointers const qualified to be safe [-Wcast-qual]
NULL, NULL, (const vImagePixelCount **)histBuffer, kvImageNoFlags);
^
>> Is it just me or does the declaration of
>vImageHistogramSpecification_ARGB8888() itself not have its consts right?
>
>desired_histogram contains input data, so it is reasonable that that
>data is declared const. I expect the pointers in the array are also
>unmodified, so they could be declared const as well (making the
>parameter const vImagePixelCount * const desired_histogram[4]), but that
>would not help; you would get essentially the same error.
Actually, it seems it does help, because it allows me to use a cast that gets no warnings, which I can't achieve with its current prototype:
--------------------------------------
#include <Accelerate/Accelerate.h>
static vImage_Error
MY_vImageHistogramSpecification_ARGB8888(
const vImage_Buffer *src,
const vImage_Buffer *dest,
const vImagePixelCount * const desired_histogram[4],
vImage_Flags flags )
{
(void)src; (void)dest;
(void)desired_histogram; (void)flags;
return 0;
}
int main (void)
{
vImagePixelCount histAlphaBuffer[256];
vImagePixelCount histRedBuffer[256];
vImagePixelCount histGreenBuffer[256];
vImagePixelCount histBlueBuffer[256];
vImagePixelCount* histBuffer[4] = {
histAlphaBuffer, histRedBuffer,
histGreenBuffer, histBlueBuffer};
vImageHistogramCalculation_ARGB8888(
NULL, histBuffer, kvImageNoFlags);
MY_vImageHistogramSpecification_ARGB8888(
NULL, NULL, (const vImagePixelCount *const *)histBuffer, kvImageNoFlags);
return 0;
}
--------------------------------------
Try with:
xcrun clang -fsyntax-only -Weverything ~/Desktop/test.c
Cheers,
desired_histogram contains input data, so it is reasonable that that
data is declared const. I expect the pointers in the array are also
unmodified, so they could be declared const as well (making the
parameter const vImagePixelCount * const desired_histogram[4]), but that
would not help; you would get essentially the same error.
Actually, it seems it does help, because it allows me to use a cast that gets no warnings, which I can't achieve with its current prototype:
…
xcrun clang -fsyntax-only -Weverything ~/Desktop/test.c
>On Jul 2, 2015, at 13:29, Sean McBride <se...@rogue-research.com> wrote:
>
>>> desired_histogram contains input data, so it is reasonable that that
>>> data is declared const. I expect the pointers in the array are also
>>> unmodified, so they could be declared const as well (making the
>>> parameter const vImagePixelCount * const desired_histogram[4]), but that
>>> would not help; you would get essentially the same error.
>>
>> Actually, it seems it does help, because it allows me to use a cast
>that gets no warnings, which I can't achieve with its current prototype:
>> …
>> xcrun clang -fsyntax-only -Weverything ~/Desktop/test.c
>
>Unfortunately, changing the declaration raises issues of compatibility
>with existing source code.
True, but there's precedent: the 10.9 SDK added a lot of consts to various Accelerate APIs (ex: rdar://13054722).
I've filed <rdar://21670389> in hope. :) It seems to me that as your compiler gets smarter/pickier, the SDKs/APIs have to keep up...
>The -Weverything switch is quite broad. I find -Wmost serves well.
I was only showing -Weverything because it's great for little snippets, I don't actually use it in my real project, it's impossibly noisy.
>you can also cast first to “void *” and then to “const vImagePixelCount
>**”, and then the warning does not appear.
Sneaky! Thanks!!
True, but there's precedent: the 10.9 SDK added a lot of consts to various Accelerate APIs (ex: rdar://13054722).
I've filed <rdar://21670389> in hope. :) It seems to me that as your compiler gets smarter/pickier, the SDKs/APIs have to keep up...
you can also cast first to “void *” and then to “const vImagePixelCount
**”, and then the warning does not appear.