-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[AVRO-4019] [C++] Turn on even more compiler warnings #2966
Conversation
Looks like it triggers some warnings:
|
Ah, Snappy ifdefs! I didn't have Snappy set up locally, so didn't see it, sorry about that! Fixed. |
lang/c++/api/LogicalType.hh
Outdated
int precision() const { return precision_; } | ||
void setScale(int scale); | ||
int scale() const { return scale_; } | ||
void setPrecision(int64_t precision); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the scale and precision a int32 is more than enough. Precision probably won't go over 38 and scale not over 77 (or -77).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I've instead added static_cast
to where we read this field
lang/c++/impl/Node.cc
Outdated
@@ -146,7 +146,7 @@ void Node::setLogicalType(LogicalType logicalType) { | |||
if (type_ == AVRO_FIXED) { | |||
// Max precision that can be supported by the current size of | |||
// the FIXED type. | |||
long maxPrecision = floor(log10(2.0) * (8.0 * fixedSize() - 1)); | |||
int32_t maxPrecision = static_cast<int32_t>(floor(log10(2.0) * (8.0 * static_cast<double>(fixedSize()) - 1))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fokko I didn't introduce this here, so I don't think I should fix it here... but I believe this calculation is incorrect.
According to the spec, the maximum precision should be:
Rust is the only language implementation that appears to implement this correctly. Python, Java, and C++ all implement this as:
JavaScript appears to have an example of a DecimalType
with this same issue, but it doesn't appear to be in any library code shipped by the library.
@Gerrit0 Got it, thanks again for working on this. There seems to be one pending issue:
|
ae81e42
to
a2c7576
Compare
@Fokko fixed and rebased, hopefully... I can't seem to get GCC to report that error locally |
@Gerrit0 same error, different line:
|
@Fokko hopefully fixed this time! Still can't seem to reproduce this locally... if this still doesn't fix it, I'll propose a change to the CI pipeline to print out the GCC version used so I can install that. |
New errors seem to pop up all the time. I'm not too familiar with the C++ build, but it would be good to list all the warnings before exiting the build. It looks like it is failing on the first warning right now. |
Also attempt to make build.sh continue
make has a Also rebased on main after the move of avro headers to |
Almost there:
|
* Update CodecTests.cc * Update DataFileTests.cc
Hopefully all fixed now! |
The build on linux aarch64 still fails ... |
I really wish I understood why different versions of gcc detect different things... I tried setting up a docker container with the same version used by CI, but ran into issues getting stuff to install, and haven't gotten back to it. |
Well, at this point my theory is that the GCC 9.4 used on ARM (vs 11.4 in the other job and 14.1 on my box) doesn't have a properly constexpr'd |
@mkmkme Do you have time to review this PR ? |
Yup, thanks for pinging me! I'll do this promptly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addeed some comments and nitpicks, please tell me if it makes sense
@@ -135,7 +135,11 @@ protected: | |||
memcpy(c, gptr(), toCopy); | |||
c += toCopy; | |||
bytesCopied += toCopy; | |||
gbump(toCopy); | |||
while (toCopy > INT_MAX) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer using numeric_limits here as using macros can be fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that first, switched to the macro when gcc 9.4 on the ARM agent was complaining about signedness... I can add a static_cast
instead, hopefully newer compilers don't flag that as a useless cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see... thanks!
You can leave it as it is now and add comment that this is only needed for old gcc compatibility.
We do need to upgrade gcc on ARM runner at some point. FYI @martin-g, that's not the first time this one bites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASF Infra team promised to upgrade the Github builders to a newer Ubuntu, but there is no timeframe ...
@@ -35,7 +35,7 @@ public: | |||
explicit NullValidator(const ValidSchema &) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file also introduces user-facing sign-ness changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I believe the new type is more appropriate here though, as a negative value isn't valid for any of these values... does this deserve a Jira issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes. Also let's hear from @martin-g as he knows better the release cycle.
But at least this should be properly documented as a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.12 is really close to be released!
The JIRA ticket is needed mostly for the CHANGELOG file, so users are aware of the change and can update their code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created https://issues.apache.org/jira/browse/AVRO-4019 to track this issue
Thank you, @Gerrit0 ! |
What is the purpose of the change
Followup to #2931, which turned on -Wextra, with this PR turning on more warnings
https://issues.apache.org/jira/browse/AVRO-4019
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Documentation