Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

__is_empty() recognizes empty unions

ipapadop
Beginner
409 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
409 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
0 Kudos
ipapadop
Beginner
409 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
0 Kudos
Milind_Kulkarni__Int
New Contributor II
409 Views
yes, i meant g++ 4.3.x or later, and that includes g++ 4.4.4, so It should be escalated and fixed.
0 Kudos
Reply