Fix -Wpointer-to-int-cast warnings in *memory.c on Windows#175
Open
rgommers wants to merge 1 commit intoxiaoyeli:masterfrom
Open
Fix -Wpointer-to-int-cast warnings in *memory.c on Windows#175rgommers wants to merge 1 commit intoxiaoyeli:masterfrom
-Wpointer-to-int-cast warnings in *memory.c on Windows#175rgommers wants to merge 1 commit intoxiaoyeli:masterfrom
Conversation
On Windows, `long int` will be 32-bit, and `stack.used` is `int_t`
which can be 64-bit. This results in warnings like:
```
[37/344] Compiling C object scipy/sparse/linalg/_dsolve/libsuperlu_lib.a.p/SuperLU_SRC_cmemory.c.obj
../scipy/sparse/linalg/_dsolve/SuperLU/SRC/cmemory.c(663,24): warning: cast to smaller integer type 'long' from 'char *' [-Wpointer-to-int-cast]
663 | Glu->stack.used -= (long int) fragment;
| ^~~~~~~~~~~~~~~~~~~
../scipy/sparse/linalg/_dsolve/SuperLU/SRC/cmemory.c(664,24): warning: cast to smaller integer type 'long' from 'char *' [-Wpointer-to-int-cast]
664 | Glu->stack.top1 -= (long int) fragment;
| ^~~~~~~~~~~~~~~~~~~
```
The fix needs to use a double cast for correctness: only `intptr_t` is
defined for pointer to integer casting, and then we need to cast again
to `int_t` to match `stack.used`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
long intwill be 32-bit, andstack.usedisint_twhich can be 64-bit. This results in warnings like (from scipy/scipy#24924):The fix needs to use a double cast for correctness: only
intptr_tis defined for pointer to integer casting, and then we need to cast again toint_tto matchstack.used.