Skip to content

fix: resolve clang >= 17 compilation error in extract<const T>() - #623

Open
jschueller wants to merge 1 commit into
esa:masterfrom
jschueller:issue584
Open

fix: resolve clang >= 17 compilation error in extract<const T>()#623
jschueller wants to merge 1 commit into
esa:masterfrom
jschueller:issue584

Conversation

@jschueller

Copy link
Copy Markdown
Contributor

The non-const get_ptr() in UDx inner classes tries to return &m_value as void*, but when T is const-qualified this drops const without an explicit cast, which clang >= 17 rejects. Use std::remove_const_t for the m_value member so &m_value is always a non-const pointer. This avoids const_cast entirely and applies uniformly across all UDx types (island, problem, algorithm, topology, bfe, s_policy, r_policy).

Closes #584.

@jschueller
jschueller marked this pull request as ready for review May 21, 2026 07:41

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

m_value is now non-const, but extract<const T>() still casts to algo_inner<const T>. Construction stores algo_inner<uncvref_t<T>>, so a const-qualified extraction still returns nullptr instead of matching the underlying UDA as the API docs promise. Please strip cv in the cast target too and add an extract<const T>() regression test.

inner classes now store m_value as remove_const_t<T> so non-const
get_ptr() returning &m_value as void* no longer drops const and
clang >=17 no longer errors. Also fix extract<const T>() which
previously cast to inner<const T> (or rejected in typeid_name_extract)
while construction stores inner<uncvref_t<T>>, causing const-qualified
extraction to return nullptr contrary to API docs. Now cast/compare
via uncvref_t<T> (and reinterpret to T*) uniformly for algorithm,
problem, island, bfe, topology, r/s_policy; typeid_name_extract now
allows cv-qualified T and compares typeid(uncvref_t<T>). Add
extract<const T>() regression test in algorithm and fix island
expectations.

Closes esa#584.
@jschueller

Copy link
Copy Markdown
Contributor Author

done, thanks

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.

[BUG] island.hpp:226:16: error: cannot initialize return object of type 'void *'

2 participants