-
Notifications
You must be signed in to change notification settings - Fork 11
Fix gcc15 const T storage #97
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
Conversation
|
Also, should |
wusatosi
left a comment
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.
Hey Thanks for the PR. I will test this once I have gcc-15 fully working on my environment.
It is currently spilling out this warning when compiling, though I question if this is actually due to this PR.
/home/.../beman/inplace_vector/tests/beman/inplace_vector/modifiers.test.cpp: In member function 'void {anonymous}::Modifiers_EraseRange_Test<gtest_TypeParam_>::TestBody() [with gtest_TypeParam_ = TestParam<NonTriviallyDefaultConstructible, 1>]':
....
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.1.0/include/c++/15/bits/stl_algobase.h:426:32: warning: 'void* __builtin_memmove(void*, const void*, long unsigned int)' reading between 5 and 1016 bytes from a region of size 4 [-Wstringop-overread]
426 | __builtin_memmove(_GLIBCXX_TO_ADDR(__result),
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
427 | _GLIBCXX_TO_ADDR(__first),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
428 | __n * sizeof(*first));
| ~~~~~~~~~~~~~~~~~~~~~~~
/home/.../beman/inplace_vector/tests/beman/inplace_vector/modifiers.test.cpp: In member function 'void {anonymous}::Modifiers_EraseRange_Test<gtest_TypeParam>::TestBody() [with gtest_TypeParam = TestParam<Trivial, 1>]':
/home/.../beman/inplace_vector/tests/beman/inplace_vector/modifiers.test.cpp:845:6: note: at offset 4 into source object 'device' of size 8
845 | IV device(reference);
| ^~~~~~
It should |
Then I guess we'll need to review the current implementation because it pretty much prevents using most constructors or functions for const T. But this is outside the scope of this PR... also what compiler settings did you use when you got the warning with 15.1? |
My installation of gcc might be buggy. We will have gcc-15 support in our CI soon(?), let's resolve this when we have gcc-15 support ready. |
git status g++-15 (Ubuntu 15-20250404-0ubuntu1) 15.0.1 20250404 (experimental) [master r15-9193-g08e803aa9be] cmake .. -DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_CXX_STANDARD=23 -G=Ninja same compiler as you and I'm able to compile your branch in both 20 and 23 mode with no warnings. In 26 mode we start getting warnings about is_trivial_v being deprecated. For fun also compiled and tested with g++-14, clang-20 with no issues. So not sure why you're having an issue? |
oops I see -- you must have made a change on the branch that stops the error: /usr/include/c++/15/bits/stl_construct.h:99:21: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] |
|
Thinking about this, I'm not seeing how https://godbolt.org/z/johqKq3YW I don't really see wording that forces this to be the case, but I might just be missing it... tldr: I'd remove const as a case and consider adding a static assert. |
|
the problem with I dont see any real world usecase of |
|
That's specified in the general container requirements which apply to inplace_vector as well |
|
@JeffGarland in the link you have provided, i only see |
You have to read the entire section and then some. To do anything useful with the container you need constructable or move assignable (can't move assign to a const object). Also, these requirements are littered about: https://eel.is/c++draft/containers#inplace.vector.cons-4 I believe this is the same path to why vector gets to the static_assert on T (it's not explicitly one thing -- and remember inplace_vector emulates vector). Anyway, there's simply nothing useful that can be done with const elements (note the entire collection can be const -- but that's different). |
|
As I understand I dont mind preventing const T with |
|
hmm, right -- we had to make this just impossible to discover the rules. You're correct that a constexpr initialization works -- but array is fixed sized with non of the dynamics of inplace_vector. Note that const isn't an option if you try to do much of anything with array either. https://eel.is/c++draft/containers#array.cons-1 Also it clearly didn't start this way in c++11 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0031r0.html |
|
@JeffGarland maybe you could address this issue in one of the weekly Beman meetings? It might be helpful to get a majority consensus on how they would expect |
|
Sorry we didn't have time to address at the sync -- and I saw this after the meeting. |
|
This has been sitting forever. gcc 15 is in the CI fleet -- apologize for holding it up. |
fix #91
tested with
g++-15 (Ubuntu 15-20250404-0ubuntu1) 15.0.1 20250404 (experimental) [master r15-9193-g08e803aa9be]onubuntu:rollingdocker imgIm not sure if this approach is correct or why the previous impl used const container for
const Tstorage