Misc warnings - #2801
Misc warnings#2801
Conversation
| using pointer = void; | ||
| using reference = void; | ||
| using _Unchecked_type = | ||
| using Unchecked_type_ = |
There was a problem hiding this comment.
This will introduce warnings in MSVC, please revert.
There was a problem hiding this comment.
What warning would it introduce?
Underscore followed by uppercase is reserved in C++: https://en.cppreference.com/w/cpp/language/identifiers
There was a problem hiding this comment.
Warnings about (un)checked iterators.
There was a problem hiding this comment.
Is _Unchecked_type some kind of Microsoft extension keyword?
There was a problem hiding this comment.
Sort of. It's not a keyword but some mechanism to opt out iterators.
There was a problem hiding this comment.
Could we somewhere do something like:
#if defined(_MSC_VER)
#define fmt_unchecked_type _Unchecked_type
#else
#define fmt_unchecked_type
#endifThere was a problem hiding this comment.
If you have access to MSVC 2015, I'd recommend checking if removing _Unchecked_type altogether still produces warnings. It might be no longer the case as IIRC they have been moving away from the checked iterators. You could even submit a test PR to the fmt repo and check warnings in appveyor: https://ci.appveyor.com/project/vitaut/fmt.
There was a problem hiding this comment.
Actually, we can see on this PR that there are definitely more warnings: https://ci.appveyor.com/project/vitaut/fmt/builds/42816914/job/briwktqjiiw9oa34. The macro approach seems OK but note that macros should be uppercase.
| using std::back_insert_iterator<detail::buffer<char>>::back_insert_iterator; | ||
| appender(base it) noexcept : base(it) {} | ||
| using _Unchecked_type = appender; // Mark iterator as checked. | ||
| using Unchecked_type_ = appender; // Mark iterator as checked. |
| #ifndef FMT_COMPILE_H_ | ||
| #define FMT_COMPILE_H_ | ||
|
|
||
| #include "core.h" |
There was a problem hiding this comment.
This is not needed: core.h is a lightweight alternative to format.h, it doesn't make sense to include it when format.h is included.
| #ifdef _MSC_VER | ||
| # define FMT_UNCHECKED_TYPE _Unchecked_type | ||
| #else | ||
| # define FMT_UNCHECKED_TYPE DummyName | ||
| #endif |
There was a problem hiding this comment.
Let's change it into:
#define FMT_UNCHECKED_ITERATOR(It) using _Unchecked_type = It; // Mark iterator as checked.to simplify call sites.
| // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. | ||
| namespace align { | ||
| enum type { none, left, right, center, numeric }; | ||
| enum type : unsigned { none, left, right, center, numeric }; |
There was a problem hiding this comment.
As per commit message: to fix the -Wsigned-enum-bitfield warnings.
| using FMT_UNCHECKED_TYPE = | ||
| truncating_iterator_base; // Mark iterator as checked. |
There was a problem hiding this comment.
This should be `FMT_UNCHECKED_TYPE(truncating_iterator_base);
There was a problem hiding this comment.
Doh, sorry I missed that one. Fixed.
| # define FMT_UNCHECKED_ITERATOR(It) using _Unchecked_type = It; // Mark iterator as checked. | ||
| #else | ||
| # define FMT_UNCHECKED_ITERATOR(It) using DummyTypeName = It; |
There was a problem hiding this comment.
Let's remove trailing semicolons since those are added at call sites.
There was a problem hiding this comment.
Ah, good point. Fixed.
|
Please fix build failures. |
|
And apply clang-format. |
I don't understand that error. I played on godbolt, and it seems to me like a gcc bug fixed between 9.2 and 9.3: https://godbolt.org/z/58aEv8zEq Interesting, the warning goes away if I change the enum from |
If that resolves the issue then sure. |
|
There are still build failures. |
|
Do you still plan working on this PR? |
Yes. But I'm at a loss as to why that old gcc complains. I don't have a means to reproduce it locally. I guess I could split that one commit out so the rest can be merged... |
Avoid defining various reserved identifiers (starting with underscore and capital letter). Fortunately, they were all Windows-only, so it was easy to conditionalize them in Window-only preprocessor checks.
Created FMT_UNCHECKED_TYPE that resolves to special identifier _Unchecked_type for Microsoft, but to a dummy string otherwise. Using _Unchecked_type is invalid because underscore + uppercase is a reserved identifier.
|
Thanks |
No description provided.