Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7568 Discussions

__is_empty() recognizes empty unions

ipapadop
Beginner
150 Views
Hi,
The following code works fine
[cpp]#include 
union empty_union { };

int main()
{
  assert(__is_empty(empty_union));
  return 0;
}[/cpp]
However, according to the latest ISO C++ 0x draft, std::is_empty should not recognize empty unions. GCC's __is_empty does not recognize empty unions as well.
Is this intentional or a bug?
Thanks
0 Kudos
3 Replies
Milind_Kulkarni__Int
New Contributor II
150 Views
I hope you compiled with g++ 4.3.x and later, as probably __is_empty does not work (and is not recognized and gives error) with 4.2.x or lower, could be due to c++0x features and functions.

I reproduced your problem, the icc & gcc give different result with __is_empty .

I would escalate it as a bug.

regards
ipapadop
Beginner
150 Views
I hope you compiled with g++ 4.3.x and later, as probably __is_empty does not work (and is not recognized and gives error) with 4.2.x or lower, could be due to c++0x features and functions.

I reproduced your problem, the icc & gcc give different result with __is_empty .

I would escalate it as a bug.

regards

I used gcc 4.4.4
Milind_Kulkarni__Int
New Contributor II
150 Views
yes, i meant g++ 4.3.x or later, and that includes g++ 4.4.4, so It should be escalated and fixed.
Reply