Skip to content

Conversation

@jl-wynen
Copy link
Member

See #3725

jl-wynen added 6 commits June 18, 2025 17:05
The behavior changed around the variadic template constructor. It matches copy-constructors and so the latter are no longer auto-generated.
This was a false-positive from a temporary ElementArrayView
// such as sc.empty are fast and do not call constructors and initialize
// memory --- in particular since this is also used internally for
// initialization the output in the implementation of many operations.
ASSERT_TRUE(std::is_pod_v<time_point>);
Copy link
Member Author

Choose a reason for hiding this comment

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

vector(const vector &other) = default;
vector(vector &&other) noexcept = default;
vector &operator=(const vector &other) = default;
vector &operator=(vector &&other) noexcept = default;
Copy link
Member Author

Choose a reason for hiding this comment

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

These are needed because the variadic constructor below matches copy-constructors but its implementation does not work in that case. It seems like the compiler no longer generates a copy-constructor in this case.

The const / non-const overloads for the copy-consdtructor are needed because given only

vector(const vector &other) = default;
template <class... Args>
vector(Args &&...args) : data(std::forward<Args>(args)...) {}

and calling it with a non-const lvalue, the variadic constructor provides a bettar match than the const copy-constructor.

for (scipp::index i = 0; i < indices.dims().volume(); ++i) {
const auto &[begin, end] = indices.values<index_pair>()[i];
const auto values = indices.values<index_pair>();
const auto &[begin, end] = values[i];
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 and other similar cases are about avoiding a false-positive lifetime warning from returning references from a temporary ElementArrayView (return value of .values()).

@MridulS
Copy link
Member

MridulS commented Jun 19, 2025

Could you also test wheel builds as a sanity check? Something like a14b8ec should trigger the builds.

@jl-wynen
Copy link
Member Author

jl-wynen commented Jun 19, 2025

Could you also test wheel builds as a sanity check? Something like a14b8ec should trigger the builds.

https://github.com/scipp/scipp/actions/runs/15757030298

The wheel builds seem to be fine. But there is a broken conda build: #3728

Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines 7 to 9
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
endif(NOT DEFINED CMAKE_CXX_STANDARD)
Copy link
Member

Choose a reason for hiding this comment

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

Is it (currently at least) still possible to compile with 20 by settings this by hand? Or are we using any 23 features?

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 possible by switching it in lib/CMakeLists.txt. Not sure if you can mix standards by changing it only in the package test. But nobody uses that anyway.

@jl-wynen jl-wynen merged commit 6910806 into main Jun 30, 2025
88 of 98 checks passed
@jl-wynen jl-wynen deleted the cxx-23 branch June 30, 2025 14:42
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.

4 participants