arocc icon indicating copy to clipboard operation
arocc copied to clipboard

pointer cast warnings too strict

Open ehaas opened this issue 3 years ago • 1 comments

This currently gives a warning when it shouldn't:

void foo(const void *arg) {
  const char * const p1 = (const char * const)arg;
}
./test.c:2:27: warning: cast to type 'const char *const ' will not preserve qualifiers [-Wcast-qualifiers]
  const char * const p1 = (const char * const)arg;
                          ^

ehaas avatar Jun 30 '22 21:06 ehaas

That error is actually talking about the second const and happens for other types as well:

void foo() {
    const char p1 = (const char)1; // warning: cast to type 'char' will not preserve qualifiers [-Wcast-qualifiers]
}

This is an warning that I added so it should either be clarified or removed altogether.

Vexu avatar Jun 30 '22 21:06 Vexu