Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pointer cast warnings too strict #325

Open
ehaas opened this issue Jun 30, 2022 · 1 comment
Open

pointer cast warnings too strict #325

ehaas opened this issue Jun 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ehaas
Copy link
Collaborator

ehaas commented Jun 30, 2022

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;
                          ^
@Vexu
Copy link
Owner

Vexu commented Jun 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants