Skip to content

Compilation Error with REFLECTCPP_USE_STD_EXPECTED=ON #570

@danielmohansahu

Description

@danielmohansahu

I'm seeing the following compilation error when building reflect-cpp v0.23.0 (commit c241a201fed6386acc7f1484ade4adaaaf75d2f8) using the REFLECTCPP_USE_STD_EXPECTED flag:

$ cmake -S . -B build -DREFLECTCPP_USE_STD_EXPECTED=ON -DCMAKE_CXX_STANDARD=23
-- The CXX compiler identification is GNU 13.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/daniel/Code/reflect-cpp/build
$ cmake --build build
[ 20%] Building CXX object CMakeFiles/reflectcpp.dir/cmake_pch.hxx.gch
In file included from /home/daniel/Code/reflect-cpp/include/rfl/Literal.hpp:13,
                 from /home/daniel/Code/reflect-cpp/include/rfl/Field.hpp:8,
                 from /home/daniel/Code/reflect-cpp/include/rfl/AddStructName.hpp:6,
                 from /home/daniel/Code/reflect-cpp/include/rfl.hpp:10,
                 from /home/daniel/Code/reflect-cpp/build/CMakeFiles/reflectcpp.dir/cmake_pch.hxx:5,
                 from <command-line>:
/home/daniel/Code/reflect-cpp/include/rfl/Result.hpp:457:14: error: expected identifier before ‘this’
  457 |   auto error(this Self&& self) noexcept {
      |              ^~~~
/home/daniel/Code/reflect-cpp/include/rfl/Result.hpp:457:14: error: expected ‘,’ or ‘...’ before ‘this’
/home/daniel/Code/reflect-cpp/include/rfl/Result.hpp: In member function ‘auto std::bad_expected_access<rfl::Error>::error(int)’:
/home/daniel/Code/reflect-cpp/include/rfl/Result.hpp:458:31: error: ‘self’ was not declared in this scope; did you mean ‘Self’?
  458 |     return std::forward<Self>(self).err_;
      |                               ^~~~
      |                               Self
gmake[2]: *** [CMakeFiles/reflectcpp.dir/build.make:80: CMakeFiles/reflectcpp.dir/cmake_pch.hxx.gch] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/reflectcpp.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2

Setting -DREFLECTCPP_USE_STD_EXPECTED=OFF builds fine.

I'm using gcc 13.3.0 on Ubuntu 24.04 - happy to provide other environment information if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions