[cfe-dev] C++11 POD bug

Suman Kar skarpio at gmail.com
Sun Jun 3 06:19:25 PDT 2012


On Sun, Jun 3, 2012 at 4:38 PM, Kal Conley <kcconley at gmail.com> wrote:
> Hi,
>
> You are probably correct about that. But the compiler isn't complaining
> about the VLA itself, only that the type is a non-POD. I think "Pod"
> should be a POD type in c++11. Here is a more direct example:
>
> $ cat pod.cc
> #include <type_traits>
> struct Pod {
>  int i;
>  Pod() = default;
> };
>
> static_assert(std::is_pod<Pod>::value, "Pod should be a POD");
>
>

As I said, this compiles just fine with my 3.2 (trunk 157155). On
further digging I found that VLAs are in fact supported by clang
(<http://clang.llvm.org/compatibility.html#vla>) as an extension. So,
the following:

$ cat vla.cpp
#include <type_traits>
struct Pod {
 int i;
 Pod() = default;
};

#if __has_extension(is_pod)
static_assert(std::is_pod<Pod>::value, "Pod should be a POD");
#endif

int main(int argc, char **argv) {
 int Size = 1;
 struct Pod PodArray[Size];
 return 0;
}

compiles fine with std=gnu++0x. You are probably better off with a
check for any type_trait member you are using (see
<http://clang.llvm.org/docs/LanguageExtensions.html#checking_type_traits>).

Can you possibly sync up and see if this problem still exists?

Regards,
Suman




More information about the cfe-dev mailing list