veselink1 / refl-cpp

Static reflection for C++17 (compile-time enumeration, attributes, proxies, overloads, template functions, metaprogramming).
https://veselink1.github.io/refl-cpp/md__introduction.html
MIT License
1.06k stars 77 forks source link

Compiler error in clang: refl::attr::property's implicitly-declared default constructor is deleted due to N3797 §8.5/7 #9

Closed Milerius closed 4 years ago

Milerius commented 4 years ago
Capture d’écran 2019-09-22 à 21 38 49
Milerius commented 4 years ago

i think we should add a basic travis and appveyor for CI verification

veselink1 commented 4 years ago

That does seem like a compiler bug. Could you please add some more details about which compiler version and what flags you are using?

Milerius commented 4 years ago

clang 8.0.1

and for flags

add_library(antara_error_settings INTERFACE)

# Using namespaces causes CMake to error our in case of typos on the
# consuming side, very important.
add_library(antara::error_settings ALIAS antara_error_settings)

##! We use only clang for simplicity
target_compile_options(
        antara_error_settings
        INTERFACE
        $<$<AND:$<PLATFORM_ID:Linux>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
        $<$<AND:$<PLATFORM_ID:Darwin>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
        $<$<AND:$<PLATFORM_ID:Windows>,$<CXX_COMPILER_ID:Clang>>:/W4 /permissive->)

##! We are using C++ 17 for all of our targets
add_library(antara_defaults_features INTERFACE)
add_library(antara::defaults_features ALIAS antara_defaults_features)
target_compile_features(antara_defaults_features INTERFACE cxx_std_17)

add_library(antara_optimize_settings INTERFACE)
add_library(antara::optimize_settings ALIAS antara_optimize_settings)

##! Msvc flags info
# /Zi - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger.
# /FS - Allows multiple cl.exe processes to write to the same .pdb file
# /DEBUG - Enable debug during linking
# /Od - Disables optimization
# /Ox - Full optimization
# /Oy- do not suppress frame pointers (recommended for debugging)

target_compile_options(antara_optimize_settings INTERFACE
        $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Linux>>:-O0 -g>
        $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Linux>>:-O2 -march=native>
        $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Darwin>>:-O0 -g>
        $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Darwin>>:-O2 -march=native>
        $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>>:/Zi /FS /DEBUG /Od /MDd /Oy->
        $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>>:/O2 -DNDEBUG>
        )

## Cross filesystem
add_library(antara_cross_filesystem INTERFACE)
add_library(antara::cross_filesystem ALIAS antara_cross_filesystem)
target_link_libraries(antara_cross_filesystem INTERFACE
        $<$<AND:$<PLATFORM_ID:Linux>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>
        $<$<PLATFORM_ID:Darwin>:c++fs>)

add_library(antara_default_settings INTERFACE)
add_library(antara::default_settings ALIAS antara_default_settings)
target_link_libraries(antara_default_settings INTERFACE antara::error_settings antara::optimize_settings antara::defaults_features antara::cross_filesystem)
Milerius commented 4 years ago

-O0 -march=native -g -DDEBUG in debug -02 -march=native -DRELEASE in Release

veselink1 commented 4 years ago

It seems that Clang is ahead of the game in regards to N3797 §8.5/7:

If a program calls for the default initialization of an object of a const-qualified type T, T shall be a class type with a user-provided default constructor.

std::optional::optional is implicitly-declared and std::optional is used by refl::attr::property, whose constructor is also implicitly-declared.

Explicitly defining property's default constructor fixes this.

veselink1 commented 4 years ago

Fixed in 4eaaeb2.