Skip to content

stlab::async will not accept non-const reference parameters #80

@ahcox

Description

@ahcox

std::async() allows passing non-const reference parameters by wrapping them in std::ref. stlab::async() fails to compile if given non-const reference parameters, whether naked or wrapped in std::ref.

Platform and Toolchain

  • MacOS Sierra 10.12.5
  • clang: Apple LLVM version 8.1.0 (clang-802.0.42)
  • stlab built with homebrew and xcode 8.3.3 following install instructions and using the develop branch July 25 head.
  • repro code built in CLion 2016.2.2.
  • Fails when compiled with any of these flags -std=c++1z, -std=c++14, -std=c++11.

Selected extracts from Clion build of repro with -v flag

Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name async_error_repro2.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -target-linker-version 278.4 -v -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -coverage-file /Users/ahcox/Library/Caches/CLion2016.2/cmake/generated/stlab_experiments-e68879c1/e68879c1/Debug/CMakeFiles/async_error_repro2.dir/async_error_repro2.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/ahcox/checkouts/stlab -I /Users/ahcox/.conan/data/Boost/1.60.0/lasote/stable/package/4224f719ca8cda8602a34d6a7dcc57685612aec9/include -stdlib=libc++ -std=c++1z -fdeprecated-macro -fdebug-compilation-dir /Users/ahcox/Library/Caches/CLion2016.2/cmake/generated/stlab_experiments-e68879c1/e68879c1/Debug -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/async_error_repro2.dir/async_error_repro2.cpp.o -x c++ /Users/ahcox/checkouts/stlab_experiments/async_error_repro2.cpp
clang -cc1 version 8.1.0 (clang-802.0.42) default target x86_64-apple-darwin16.6.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/Library/Frameworks"
...
#include <...> search starts here:
 /Users/ahcox/checkouts/stlab
 /Users/ahcox/.conan/data/Boost/1.60.0/lasote/stable/package/4224f719ca8cda8602a34d6a7dcc57685612aec9/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks (framework directory)
...

Repro

A simple example showing this is here: https://gist.github.com/ahcox/0e76d32a0a87ac24160bf50298052a1d
The log from the compile failure is here: https://gist.github.com/ahcox/9ce507f383ec7820fc245f9ea90297ee

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions