[LLVMbugs] [Bug 13685] New: is_pod not correct according to new standard

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 23 22:08:13 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13685

             Bug #: 13685
           Summary: is_pod not correct according to new standard
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dansunderland at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


POD Requirements (since C++11):
Either
  ScalarType

Or a class type (class or struct or union) that is
  TrivialType
  StandardLayoutType
  has no non-static members that are non-POD
  or an array of such type

#include <type_traits>
#include <iostream>

struct A //is_pod
{
  int m_value;
};

struct B //is_pod according to new standard, but reported as false
{
  B() = default;
  int m_value;
};

struct C //is_pod according to new standard, but reported as false
{
  C() = default;
  C(int m) : m_value(m) {}
  int m_value;
};


template<typename T>
void print_traits(T) 
{
  std::cout << "  is_trivial: " << std::is_trivial<T>::value << std::endl;
  std::cout << "  is_trivially_copyable: " <<
std::is_trivially_copyable<T>::value << std::endl;
  std::cout << "  is_standard_layout: " << std::is_standard_layout<T>::value <<
std::endl;
  std::cout << "  is_default_constructible: " <<
std::is_default_constructible<T>::value << std::endl;
  std::cout << "  is_trivially_default_constructible: " <<
std::is_trivially_default_constructible<T>::value << std::endl;
  std::cout << "  is_nothrow_default_constructible: " <<
std::is_nothrow_default_constructible<T>::value << std::endl;
  std::cout << "  is_pod: " << std::is_pod<T>::value << std::endl;


}


int main()
{
  std::cout << "A:" << std::endl;
  print_traits(A());
  std::cout << std::endl;

  std::cout << "B:" << std::endl;
  print_traits(B());
  std::cout << std::endl;

  std::cout << "C:" << std::endl;
  print_traits(C());
  std::cout << std::endl;

  return 0;
}

****************Output********************

Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix

clang++ -Wall -std=c++0x -std=libc++ main.cpp

./a
A:
  is_trivial: 1
  is_trivially_copyable: 1
  is_standard_layout: 1
  is_default_constructible: 1
  is_trivially_default_constructible: 1
  is_nothrow_default_constructible: 1
  is_pod: 1

B:
  is_trivial: 1
  is_trivially_copyable: 1
  is_standard_layout: 1
  is_default_constructible: 1
  is_trivially_default_constructible: 1
  is_nothrow_default_constructible: 0
  is_pod: 0

C:
  is_trivial: 1
  is_trivially_copyable: 1
  is_standard_layout: 1
  is_default_constructible: 1
  is_trivially_default_constructible: 1
  is_nothrow_default_constructible: 0
  is_pod: 0

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list