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

questionable casts and other warnings #138

Open
fuchsi-fuchs opened this issue Aug 9, 2016 · 5 comments
Open

questionable casts and other warnings #138

fuchsi-fuchs opened this issue Aug 9, 2016 · 5 comments

Comments

@fuchsi-fuchs
Copy link

Using autobahn with the compiler flags that I typically use leads to a large list of errors. Among them are

  • many old-style casts(-Wold-style-cast), some of which are used as const-casts (!) (-Wcast-qual)
  • many shadowed variables (-Wshadow)
  • missing default cases in switch statements (-Wswitch-default)
  • implicit conversions, e.g. from unsigned long to int (!) (-Wconversion)
  • ignored type qualifiers on functions (-Wignored-qualifiers)

This seems to conflict with the otherwise well written modern c++ code, so I think it should be fixed (as many of these warnings can indicate mistakes or bugs).

@j-mullen
Copy link
Contributor

j-mullen commented Aug 9, 2016

You should add -Wunused-variable to this list, among others I can't remember (not sitting at a terminal at the moment).

I do know, however, I cannot compile when using -Werror; which is a standard flag for many of the projects I work on personally and at work. I had seriously considered fixing many of these on my fork, but I haven't had the time to spare.

@fuchsi-fuchs
Copy link
Author

I just listet those, for which I saw some errors. Below is the full list I typically use for the gcc. It is very well possible to write code that produces no warnings with all of these flags, so I don't see a reason not to do so ;) (-Wunused-variable is included in -Wall)

-Wall -Wextra -pedantic -Wundef -Wunreachable-code -Wdisabled-optimization -Wcast-qual -Wsign-promo -Winit-self -Wnon-virtual-dtor -Woverloaded-virtual -Wconversion -Wfloat-equal -Wshadow -Wswitch-default -Wpacked -Wcast-align -Wold-style-cast -Wuseless-cast -Wlogical-op -Wtrampolines -Wnoexcept

@oberstet
Copy link
Contributor

-Wall is fine. If you want to get crazy, start making Boost compile with you excessive list of flags without warnings.

@fuchsi-fuchs
Copy link
Author

I do use boost and don't get any warnings. And everything I have described might not be a problem (yet), but some of them are mistakes. Even if you do have to handle some GiB of data such that the cast from unsigned long (std::size_t) to int is ever a problem...
Similarly, claiming that a function returns a const bool is also a mistake simply because it is impossible for any function to do so.

@oberstet oberstet reopened this Sep 14, 2016
@oberstet
Copy link
Contributor

@BenHuber I see. Such casts are definitely questionable. So yeah, we should go over the code base and fix these things ..

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

No branches or pull requests

3 participants