Skip to content

Non C++17 CUDA compilation is broken when STL headers are included  #2020

@gevtushenko

Description

@gevtushenko

Hello, I'm using fresh VS install (16.10.2). When I compile the following code sample everything is fine:

#include <stdio.h>

int main() {
    printf("+");
    return 0;
}

But STL usage:

#include <string>

int main() {
    return static_cast<int>(std::string("hello").size());
}

leads to the following compilation errors

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(62): error: expected a "("
          detected during:
            instantiation of "size_t std::_Get_size_of_n<_Ty_size>(size_t) [with _Ty_size=16ULL]" 
(839): here
            instantiation of "_Ty *std::allocator<_Ty>::allocate(size_t) [with _Ty=std::_Container_proxy]" 
(1321): here
            instantiation of "std::_Container_proxy_ptr12<_Alloc>::_Container_proxy_ptr12(_Alloc &, std::_Container_base12 &) [with _Alloc=std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator<char>, char>, std::_Container_proxy>]" 
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xstring(2501): here
            instantiation of "std::basic_string<_Elem, _Traits, _Alloc>::basic_string(const _Elem *, std::basic_string<_Elem, _Traits, _Alloc>::size_type) [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" 
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xstring(4997): here

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xutility(131): error: expected a "("
          detected during:
            instantiation of "void *std::_Voidify_iter(_Iter) [with _Iter=std::_Container_proxy *]" 
(158): here
            instantiation of "void std::_Construct_in_place(_Ty &, _Types &&...) [with _Ty=std::_Container_proxy, _Types=<std::_Container_base12 *>]" 

If I change the standard version to C++17 - everything works fine. It seems that there is an unguarded if constexpr usage in the STL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions