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

warnings under Xcode 6.1.1 (probably with -Weverything) #96

Closed
dixlorenz opened this issue Feb 6, 2015 · 7 comments
Closed

warnings under Xcode 6.1.1 (probably with -Weverything) #96

dixlorenz opened this issue Feb 6, 2015 · 7 comments

Comments

@dixlorenz
Copy link
Contributor

commit ba17cca, 2/6/2015:

format.h:
Unknown Command Tag Name:
line #142: /rst
line #164: \endrst
line #1567: out.write("Current point:\n");
the last one ist about "\n"; this might well be an Xcode bug

format.cpp:
Semantic issue, 'return' will never be executed
line #254, line #276
these returns are after an unconditional FMT_THROW

warning: comparison of integers of different signs: 'const int' and 'std::size_t' (aka 'unsigned long')
line #628: if (spec.precision_ >= 0 && spec.precision_ < str_size)
spec.precision_ and str_size are the problem.

@dixlorenz
Copy link
Contributor Author

one more: in Result visit(const Arg &arg) clang complains about the fallthrough in release mode and suggests inserting [[clang::fallthrough]]. This gives a warning in debug mode though, because after the assert(false) it is unreachable code.

@vitaut
Copy link
Contributor

vitaut commented Feb 8, 2015

Reopening until the fallthrough warning is resolved.

@vitaut vitaut reopened this Feb 8, 2015
@vitaut
Copy link
Contributor

vitaut commented Feb 8, 2015

@dixlorenz Could you please check if the fix in branch fallthrough resolves the fallthrough warning? I tried detecting the availability of [[clang::fallthrough]] based on clang version there (you might need to change 600 to your version in https://github.com/cppformat/cppformat/blob/fallthrough/format.h#L124 if it is lower).

@dixlorenz
Copy link
Contributor Author

Almost perfect. It resolves the fallthrough warning, but in debug build I now get

warning: fallthrough annotation in unreachable code

because of the assert(false)... Somewhat interestingly (to me): this code

default:
  assert(false);
  return FMT_DISPATCH(visit_int(arg.int_value));
case Arg::INT:
  return FMT_DISPATCH(visit_int(arg.int_value));

does not give a warning about unreachable code (or any other).

That might be the easiest/cleanest solution. It does have the same semantics as the fallthrough and doesn't need macros, #ifdefs or rely on the compiler or its version at all.

@vitaut
Copy link
Contributor

vitaut commented Feb 9, 2015

So does this commit fixes the warnings? (I used your suggestion but simplified it a bit since there is no need to dispatch there.) If it works I'll merge it into master and remove the fallthrough attribute detection.
Thanks!

@dixlorenz
Copy link
Contributor Author

That works perfectly, no warning, neither in debug or in release.

@vitaut
Copy link
Contributor

vitaut commented Feb 9, 2015

Closing the issue via 04a21bb then. Thanks again for your help.

@vitaut vitaut closed this as completed Feb 9, 2015
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

2 participants