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

tbb_exception.h compiler warnings

Blue_Sky_Studios
Beginner
306 Views
We have started to use tbb_exception and have immediately encountered a warning everytime a source file includes the header:

.../tbb/tbb_exception.h: In copy constructor tbb::captured_exception::captured_exception(const tbb::captured_exception&):
.../tbb/tbb_exception.h:108: warning: base class class tbb::tbb_exception should be explicitly initialized in the copy constructor

We are using tbb21_017oss. (CHANGES indicates that this is "TBB 2.1 Update 4 commercial-aligned release.")

The compiler is g++ 4.1.2 (gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)) running on 64-bit Fedora 7 Linux. We use -Wall when compiling debug versions.

We prefer to see no warnings when we compile our code, so the presence of this warning from tbb_exception.h for every file that includes it makes it difficult to find problems that we introduce ourselves.

Is there any chance that this might get fixed in the next release? If there is, when might that be?
0 Kudos
3 Replies
Alexey-Kukanov
Employee
306 Views
TBB headers compile cleanly with -Wall. This warning is enabled by -Wextra, which is beyond our target for warnings. Itis unfeasible to clean every warning of every compiler, especially with some warning workarounds just adding code clutter for no good reason.

I will checkwith the team whether it makes sense to fix this particular warning. Chances are that we will do that, solely because tbb_exception inherits std::exception, which has a copy constructor. tbb_exception by itself is an abstract class without any additional state, and so does not need any constructor on its own.
0 Kudos
Blue_Sky_Studios
Beginner
306 Views
TBB headers compile cleanly with -Wall. This warning is enabled by -Wextra, which is beyond our target for warnings. Itis unfeasible to clean every warning of every compiler, especially with some warning workarounds just adding code clutter for no good reason.

I will checkwith the team whether it makes sense to fix this particular warning. Chances are that we will do that, solely because tbb_exception inherits std::exception, which has a copy constructor. tbb_exception by itself is an abstract class without any additional state, and so does not need any constructor on its own.
Thanks for checking. Yes, we are using -W (aka -Wextra) as well as -Wall.

Since you mention tbb_exception not needing a copy constructor, I should clarify that the warning arises with classes derived from tbb_exception, e.g., captured_exception. It is this class's copy constructor that could explicitly initialize its tbb_exception base. The movable_exception template class could do the same.

Of course, I can fix the problem in our copy of TBB, but it would be nicer not to do this for every new release.
0 Kudos
Alexey-Kukanov
Employee
306 Views
Quoting - hadsell
Since you mention tbb_exception not needing a copy constructor, I should clarify that the warning arises with classes derived from tbb_exception, e.g., captured_exception. It is this class's copy constructor that could explicitly initialize its tbb_exception base. The movable_exception template class could do the same.

Right. But to do explicit initialization of tbb_exception, you need a constructor of it. Fortunately, compiler should generate a copy constructor for it which will do just the right thing of calling copy constructor for its base class, std::exception. So we decided to add the call there, not in order to have no warning but to have the std::exception part copy-constructed correctly. If tbb_exception would not inherit std::exception, there would be no sense in calling its constructor, since it would basically be a no-op.

The change was committed to TBB mainline, so sooner or later it will appear in releases (including COM-aligned).
0 Kudos
Reply