LoopPerfect / neither

Either and Maybe monads for better error-handling in C++ ↔️
MIT License
249 stars 18 forks source link

Build fails on Windows 10 using Visual C++ 2019 with Bazel #32

Open yesudeep opened 4 years ago

yesudeep commented 4 years ago

I'm using the Visual C++ 19.27.29110 compiler on Windows 10.

❯ bazel test "@com_loopperfect_neither//:all_tests"
INFO: Analyzed 4 targets (0 packages loaded, 0 targets configured).
INFO: Found 4 test targets...
ERROR: C:/tmp/yhlvxsm5/external/com_loopperfect_neither/BUILD.bazel:42:8: C++ compilation of rule '@com_loopperfect_neither//:lift_test' failed (Exit 2): cl.exe failed: error executing command
  cd C:/tmp/yhlvxsm5/execroot/__main__
  SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt
    SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
    SET PWD=/proc/self/cwd
    SET TEMP=C:\Users\yesudeep\AppData\Local\Temp
    SET TMP=C:\Users\yesudeep\AppData\Local\Temp
  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/HostX64/x64/cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /bigobj /Zm500 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /Iexternal/com_loopperfect_neither /Ibazel-out/x64_windows-fastbuild/bin/external/com_loopperfect_neither /Iexternal/com_google_googletest /Ibazel-out/x64_windows-fastbuild/bin/external/com_google_googletest /Iexternal/bazel_tools /Ibazel-out/x64_windows-fastbuild/bin/external/bazel_tools /Ibazel-out/x64_windows-fastbuild/bin/external/com_loopperfect_neither/_virtual_includes/neither /Iexternal/com_loopperfect_neither/neither/include /Ibazel-out/x64_windows-fastbuild/bin/external/com_loopperfect_neither/neither/include /Iexternal/com_google_googletest/googlemock /Ibazel-out/x64_windows-fastbuild/bin/external/com_google_googletest/googlemock /Iexternal/com_google_googletest/googlemock/include /Ibazel-out/x64_windows-fastbuild/bin/external/com_google_googletest/googlemock/include /Iexternal/com_google_googletest/googletest /Ibazel-out/x64_windows-fastbuild/bin/external/com_google_googletest/googletest /Iexternal/com_google_googletest/googletest/include /Ibazel-out/x64_windows-fastbuild/bin/external/com_google_googletest/googletest/include /showIncludes /MD /Od /Z7 /wd4117 -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -DHAVE_BAZEL_BUILD /DHAVE_BAZEL_BUILD_WINDOWS /D_HAS_DEPRECATED_RESULT_OF=1 /std:c++latest /Fobazel-out/x64_windows-fastbuild/bin/external/com_loopperfect_neither/_objs/lift_test/lift.obj /c external/com_loopperfect_neither/neither/tests/lift.cpp
Execution platform: @local_config_platform//:host
C:\tmp\yhlvxsm5\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\external\com_loopperfect_neither\_virtual_includes\neither\neither/either.hpp(149): error C2560: 'common_type<L2,R2>::type neither::Either<L,R>::join(void) &&': cannot overload a member function with ref-qualifier with a member function without ref-qualifier
C:\tmp\yhlvxsm5\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\external\com_loopperfect_neither\_virtual_includes\neither\neither/either.hpp(304): note: see reference to class template instantiation 'neither::Either<L,R>' being compiled
INFO: Elapsed time: 2.906s, Critical Path: 1.80s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
@com_loopperfect_neither//:either_test                                NO STATUS
@com_loopperfect_neither//:maybe_test                                 NO STATUS
@com_loopperfect_neither//:try_test                                   NO STATUS
@com_loopperfect_neither//:lift_test                            FAILED TO BUILD

FAILED: Build did NOT complete successfully

Bazel build file for reference:

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

licenses(["notice"])  # MIT License

exports_files(["LICENSE.txt"])

cc_library(
    name = "neither",
    hdrs = [
        "neither/include/either.hpp",
        "neither/include/lift.hpp",
        "neither/include/maybe.hpp",
        "neither/include/neither.hpp",
        "neither/include/traits.hpp",
        "neither/include/try.hpp",
    ],
    include_prefix = "neither",
    includes = ["neither/include"],
    linkstatic = True,
    strip_include_prefix = "neither/include",
    visibility = ["//visibility:public"],
)

test_suite(
    name = "all_tests",
    tests = [
        ":either_test",
        ":lift_test",
        ":maybe_test",
        ":try_test",
    ],
)

cc_test(
    name = "either_test",
    size = "small",
    srcs = [
        "neither/tests/either.cpp",
    ],
    deps = [
        ":neither",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "lift_test",
    size = "small",
    srcs = [
        "neither/tests/lift.cpp",
    ],
    deps = [
        ":neither",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "maybe_test",
    size = "small",
    srcs = [
        "neither/tests/maybe.cpp",
    ],
    deps = [
        ":neither",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "try_test",
    size = "small",
    srcs = [
        "neither/tests/try.cpp",
    ],
    deps = [
        ":neither",
        "@com_google_googletest//:gtest_main",
    ],
)
nikhedonia commented 4 years ago

Thanks for opening this issue and sharing your bazel file!

Seems like it fails due to this error:

ct_neither\_virtual_includes\neither\neither/either.hpp(149): error C2560: 'common_type<L2,R2>::type neither::Either<L,R>::join(void) &&': cannot overload a member function with ref-qualifier with a member function without ref-qualifier

I need to double check if there is a workaround for this issue in visual studio compiler, afaik this is standard conform; Worst case we need to disable this overload for visual studio