Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

The code compiles in VS2013 but doesn't in clang and gcc

$
0
0
#include <iostream>
#include <thread>

class A
{
    public:
    void operator()() const { std::cout << 'A' << '\n'; }
};

int main()
{
    std::thread t(A{});
    t.detach();
}

As can be seen here the code compiles and prints 'A' in VS2013, but the code doesn't compile in clang and gcc. If I process the code in clang incoliru, it compiles, but doesn't print 'A'. What's happening here?

Edit:  I should have said above,  "but the code doesn't compile in clang and emits a run-time error in gcc", instead of "but the code doesn't compile in clang and gcc".





Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>