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

Remove const pointer cast #245

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

tathanhdinh
Copy link

Hi all,

Returning a const value does not have much meaning, indeed CppCoreGuidelines notes:

...
It is not recommended to return a const value. Such older advice is now obsolete; it does not add value, and it interferes with move semantics.

So the second const in, for example:

x64asm/src/r.cc

Line 221 in 505ab5e

return static_cast<const Rh* const>(this)->write_att(os);

can be removed as

return static_cast<const Rh*>(this)->write_att(os);

In recent version of g++, the compiler reports:

ccache g++ -Werror -Wextra -Wall -Wfatal-errors -pedantic -Wno-unused-parameter -Wno-reorder -std=c++11 -fPIC -DNDEBUG -O3 -I./ -c src/r.cc -o src/r.o
src/r.cc: In member function 'std::ostream& x64asm::R::write_att(std::ostream&) const':
src/r.cc:247:47: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
     return static_cast<const R64 * const>(this)->write_att(os);

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

Successfully merging this pull request may close these issues.

1 participant