Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2464 Discussions

TBB tuple doesn't compile with Xcode 4.4 (clang 4.0)

robmorgan
Beginner
231 Views
After upgrading to the latest Xcode 4.4 which has clang 4.0 (based on llvm 3.1), the tbb/compat/tuple header fails to compile.

$ clang --version

Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)

Target: x86_64-apple-darwin11.4.0

Thread model: posix

$ make compiler=clang arch=intel64 test

[cut uninteresting output ...]

clang++ -c -MMD -O2 -DUSE_PTHREAD -m64 -Wall -Wextra -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor -I../../src -I../../src/rml/include -I../../include -I. ../../src/test/test_eh_flow_graph.cpp

In file included from ../../src/test/test_eh_flow_graph.cpp:32:

In file included from ../../include/tbb/flow_graph.h:45:

../../include/tbb/compat/tuple:496:67: error: expected expression

get(tuple& t) { return t.get(); }

^

../../include/tbb/compat/tuple:500:73: error: expected expression

get(const tuple& t) { return t.get(); }

^

2 errors generated.

make[1]: *** [test_eh_flow_graph.o] Error 1

make: [test] Error 2 (ignored)


Apparently the compiler has a problem with the call to the tuple::get() instance method. It's not clear why; this code compiles with every other compiler I've tried.

I was able to work around the problem by replacing the call to tuple::get() with a call to internal::get_helper::get() (which is how tuple::get() is itself implemented). If anyone can come up with a cleaner workaround I'd be happy to hear it.

Here's the patch:

diff --git a/tbb40_20120613oss/include/tbb/compat/tuple b/tbb40_20120613oss/include/tbb/compat/tuple

index 0c8721c..120b55f 100644

--- a/tbb40_20120613oss/include/tbb/compat/tuple

+++ b/tbb40_20120613oss/include/tbb/compat/tuple

@@ -493,11 +493,11 @@ struct tuple_element {

template

inline static typename tuple_element >::type&

- get(tuple& t) { return t.get(); }

+ get(tuple& t) { return internal::get_helper::get(t); }

template

inline static typename tuple_element >::type const&

- get(const tuple& t) { return t.get(); }

+ get(const tuple& t) { return internal::get_helper::get(t); }

} // interface5

} // tbb

0 Kudos
1 Reply
Vladimir_P_1234567890
231 Views
Thank you for a report, We have the issue on both Lion and Mountain Lion using August command line tools. It looks like a compiler bug.:) Could you submit a patch via http://threadingbuildingblocks.org/contribution_first.php to include it to tbb update in case we do not find a better solution? Thanks, Vladimir
0 Kudos
Reply