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

GCC 8 warning in octree_key.h:143 type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] #2404

Closed
alspitz opened this issue Aug 30, 2018 · 4 comments

Comments

@alspitz
Copy link
Contributor

alspitz commented Aug 30, 2018

static const unsigned char maxDepth = static_cast<const unsigned char>(sizeof(uint32_t)*8);

Your Environment

  • Compiler: gcc (Ubuntu 8-20180414-1ubuntu2) 8.0.1 20180414 (experimental) [trunk revision 259383]
  • PCL Version: 1.8

Expected Behavior

The header files should compile without warnings.

Current Behavior

The header file octree_key.h fails to compile with the GCC 8 warning -Wignored-qualifiers.

Possible Solution

I believe const unsigned char should be changed to unsigned char in the static_cast.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Aug 30, 2018

The header file octree_key.h fails to compile with the GCC 8 warning -Wignored-qualifiers.

How exactly is it failing to compile if it's a warning and not an error?

Edit: Just noticed you passed Werror on the title. That's a ballsy flag to employ.

I believe const unsigned char should be changed to unsigned char in the static_cast.

The idea from the original author is that maxDepth is not meant to be changed and that is why it is has a const qualifier. At first sight, the only thing I see "wrong" with that line is the fact that the initialization is done inline instead of being done on the implementation file.

I'm surprised about the warning and I'm confused why it is appearing. Thanks for reporting.

@SergioRAgostinho SergioRAgostinho added needs: code review Specify why not closed/merged yet module: octree labels Aug 30, 2018
@alspitz
Copy link
Contributor Author

alspitz commented Aug 30, 2018

I think GCC is warning that adding const to the static cast type doesn't do anything. So casting to a const unsigned char is the same as casting to an unsigned char. It's a rather pedantic warning, but still, would be nice if it is fixed.

Of course, maxDepth should keep the const qualifier, it's only the static cast type that should change.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Aug 30, 2018 via email

@alspitz
Copy link
Contributor Author

alspitz commented Aug 30, 2018

Done, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants