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

Add Werror to CI #56277

Merged
merged 14 commits into from
Dec 6, 2023
Merged

Add Werror to CI #56277

merged 14 commits into from
Dec 6, 2023

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Dec 1, 2023

@WillAyd WillAyd requested a review from mroeschke as a code owner December 1, 2023 04:59
@@ -12,7 +12,7 @@ The full license is in the LICENSE file, distributed with this software.
#include <numpy/ndarraytypes.h>

// Scales value inplace from nanosecond resolution to unit resolution
int scaleNanosecToUnit(npy_int64 *value, NPY_DATETIMEUNIT unit);
int scaleNanosecToUnit(int64_t *value, NPY_DATETIMEUNIT unit);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phofl pointed out on macOS that npy_int64 is a typedef for a long whereas int64_t is a typedef for a long long. Unfortunately referencing these via pointer violates the strict aliasing rule

For now just picked int64_t as it was bigger. I'm not sure in practice that this matters to much, but we do freely mix these uses today

NPY_DATETIMEUNIT dateUnit = NPY_FR_ns;
if (PyTypeNum_ISDATETIME(type_num)) {
is_datetimelike = 1;
i8date = *(npy_int64 *)dataptr;
i8date = *(int64_t *)dataptr;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a safe cast, but leaving to another PR to fix. The proper way to do this would be via memcpy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @seberg said the cast was fine, when I added this in #56114.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is likely pedantic but I'm fairly certain this is a strict aliasing violation. Where/when that matters may be up for debate. The memcpy from that comment would seemingly be safer

@WillAyd
Copy link
Member Author

WillAyd commented Dec 5, 2023

Any feedback on this? Would love to get this one in before any other PRs that touch extensions

// value exceeds number of bits that significand can hold
int64_t value = PyObject_HasAttrString(obj, "_value")
? get_long_attr(obj, "_value")
: (int64_t)total_seconds(obj) * 1000000000LL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the int64_t cast apply to total_seconds(obj) first? I think this would truncate e.g. Timedelta(milliseconds=1) to 0 first before multiplying by 1000000000LL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice catch - I think you are right about that. Let me see if we can add a test for that

@mroeschke mroeschke added the CI Continuous Integration label Dec 5, 2023
@mroeschke mroeschke added this to the 2.2 milestone Dec 6, 2023
@mroeschke mroeschke merged commit 7808ecf into pandas-dev:main Dec 6, 2023
44 checks passed
@mroeschke
Copy link
Member

Great to have this back running @WillAyd

@WillAyd WillAyd deleted the ci-werror branch December 10, 2023 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add -Werror to CI (or at least show warnings)
3 participants