You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example, if I use GCC and the "-Wcast-qual" is treated as an error:
#include <EASTL/optional.h>
#include <optional>
struct S
{
std::optional<int> opt_std;
eastl::optional<int> opt_eastl;
int get_std() const
{
return opt_std.has_value() ? opt_std.value() : 0;
}
int get_eastl() const
{
return opt_eastl.has_value() ? opt_eastl.value() : 0;
}
};
int main()
{
S opt_wrap;
const int std_val = opt_wrap.get_std();
const int eastl_val = opt_wrap.get_eastl();
return 0;
}
I get a compilation error from EASTL optional.h:
include/EASTL/optional.h: In instantiation of 'eastl::optional<T>::value_type& eastl::optional<T>::get_value_ref() const [with T = int; eastl::optional<T>::value_type = int]':
include/EASTL/optional.h:351:64: required from 'const T& eastl::optional<T>::value() const & [with T = int]'
main.cpp:16:56: required from here
include/EASTL/optional.h:468:15: error: cast from type 'const eastl::aligned_storage<4, 4>::type*' to type 'eastl::optional<int>::value_type*' {aka 'int*'} casts away qualifiers [-Werror=cast-qual]
return *(value_type*)eastl::addressof(val);
It seems like there is an implementation issue in eastl::optional, whereas std::optional works fine. Maybe a const is missing from the cast:
inline const value_type& get_value_ref() const EASTL_OPTIONAL_NOEXCEPT
{
#if EASTL_EXCEPTIONS_ENABLED
if(!engaged)
throw bad_optional_access();
#elif EASTL_ASSERT_ENABLED
EASTL_ASSERT_MSG(engaged, "no value to retrieve");
#endif
return *(value_type*)eastl::addressof(val);
}
The text was updated successfully, but these errors were encountered:
In this example, if I use GCC and the "-Wcast-qual" is treated as an error:
I get a compilation error from EASTL optional.h:
It seems like there is an implementation issue in
eastl::optional
, whereasstd::optional
works fine. Maybe aconst
is missing from the cast:The text was updated successfully, but these errors were encountered: