Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

thread_local compiler bug

$
0
0

Using "Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20160415" on Windows will cause the following simple code to crash pretty much every time.  Is this a compiler bug?  Anyway around this now or will I have to wait for icc 17 and if so, how long will that take?

// icl local_thread.cpp
#include <thread>
#include "stdio.h"

struct ThreadObj
{
	void get_tls()
	{
		thread_local int tid;
		printf("&tid %p\n", &tid);
		printf("tid  %d\n", tid);
	}
};

void ThreadFunc(ThreadObj* t)
{
	t->get_tls();
}

int main()
{
	const int num_threads = 256;
	std::thread threads[num_threads];

	for (int i = 0; i < num_threads; ++i)
		threads[i] = std::thread(ThreadFunc, new ThreadObj());

	for (int i = 0; i < num_threads; ++i)
		threads[i].join();

	return 0;
}

 

Thread Topic: 

Bug Report

Viewing all articles
Browse latest Browse all 1175


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