Skip to content

Conversation

@RomaLzhih
Copy link

The malloc returns the raw pointer, which needs to be explicitly cast to the desired type to avoid a compile issue in C++20.

@wheatman
Copy link
Owner

What compiler version and build target/ flag combination do you see this issue on?
And is it a warning or an error.
It builds clean for me using c++20 on clang 20 with no warnings.
It also builds using gcc 13.2, though this one has many warnings.

I want to make sure to build and test all configurations

@RomaLzhih
Copy link
Author

This compilation error arises when I try to extend the BYO.

I am using g++ 14.2.1.

To reproduce, you can try cloning my fork and running

bazel build benchmarks/run_structures:run_pcsr 

Below is the error message on my side:

external/cpma/PMA/CPMA.hpp|1185 col 17| error: invalid conversion from 'void*' to 'void**' [-fpermissive]
||  1185 |           malloc(offsets_array.size * sizeof(*(offsets_array.locations)));
||       |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||       |                 |
||       |                 void*
external/cpma/PMA/CPMA.hpp|1187 col 17| error: invalid conversion from 'void*' to 'unsigned int*' [-fpermissive]
||  1187 |           malloc(offsets_array.size * sizeof(*(offsets_array.degrees)));
||       |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||       |                 |
||       |                 void*
|| Target //benchmarks/run_structures:run_pcsr failed to build

I have noticed that there are several similar pointer-type changes in the same file, yet the compiler reports no errors.

Thanks very much!

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

Successfully merging this pull request may close these issues.

2 participants