Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61942 - trunk/libs/config/test
From: nielsdekker_at_[hidden]
Date: 2010-05-13 08:11:59


Author: niels_dekker
Date: 2010-05-13 08:11:58 EDT (Thu, 13 May 2010)
New Revision: 61942
URL: http://svn.boost.org/trac/boost/changeset/61942

Log:
Added value-initialization checks for pointer-to-member.
Text files modified:
   trunk/libs/config/test/boost_no_com_value_init.ipp | 42 +++++++++++++++++++++++++++++++++++++--
   1 files changed, 39 insertions(+), 3 deletions(-)

Modified: trunk/libs/config/test/boost_no_com_value_init.ipp
==============================================================================
--- trunk/libs/config/test/boost_no_com_value_init.ipp (original)
+++ trunk/libs/config/test/boost_no_com_value_init.ipp 2010-05-13 08:11:58 EDT (Thu, 13 May 2010)
@@ -13,7 +13,7 @@
 #include <iostream>
 
 // This test checks various forms of value-initialization:
-// - doing member initialization inside a constructor
+// - doing subobject initialization inside a constructor
 // - creating a temporary object by T()
 // - creating a heap object by doing new T()
 // It checks various DefaultConstructible types, including fundamental types,
@@ -138,6 +138,24 @@
     return arg.data == 0;
   }
 
+ struct int_pair_struct
+ {
+ int first;
+ int second;
+ };
+
+ typedef int int_pair_struct::*ptr_to_member_type;
+
+ struct ptr_to_member_struct
+ {
+ ptr_to_member_type data;
+ };
+
+ bool is_value_initialized(const ptr_to_member_struct& arg)
+ {
+ return arg.data == 0;
+ }
+
   // A struct, having an int. Equivalent to the struct TData, from CodeGear bug
   // report 51854, "Value-initialization: POD struct should be zero-initialized",
   // reported by me (Niels Dekker, LKEB) in 2007:
@@ -432,7 +450,7 @@
 
 
 
- // For built-in types and enumerated types.
+ // Tells whether an object of a scalar type T is value-initialized.
   template <class T>
   bool is_value_initialized(const T& arg)
   {
@@ -547,6 +565,10 @@
     member_function_ptr_type m_member_function_ptr_array[2];
     member_function_ptr_struct m_member_function_ptr_struct;
     member_function_ptr_struct m_member_function_ptr_struct_array[2];
+ ptr_to_member_type m_ptr_to_member;
+ ptr_to_member_type m_ptr_to_member_array[2];
+ ptr_to_member_struct m_ptr_to_member_struct;
+ ptr_to_member_struct m_ptr_to_member_struct_array[2];
     bit_field_struct m_bit_field_struct;
     bit_field_struct m_bit_field_struct_array[2];
     int_struct m_int_struct;
@@ -635,6 +657,10 @@
     m_member_function_ptr_array(),
     m_member_function_ptr_struct(),
     m_member_function_ptr_struct_array(),
+ m_ptr_to_member(),
+ m_ptr_to_member_array(),
+ m_ptr_to_member_struct(),
+ m_ptr_to_member_struct_array(),
     m_bit_field_struct(),
     m_bit_field_struct_array(),
     m_int_struct(),
@@ -732,6 +758,12 @@
         FAILED_TO_VALUE_INITIALIZE(m_member_function_ptr_struct) +
         FAILED_TO_VALUE_INITIALIZE(m_member_function_ptr_struct_array[0]) +
         FAILED_TO_VALUE_INITIALIZE(m_member_function_ptr_struct_array[1]) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member_array[0]) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member_array[1]) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member_struct) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member_struct_array[0]) +
+ FAILED_TO_VALUE_INITIALIZE(m_ptr_to_member_struct_array[1]) +
         FAILED_TO_VALUE_INITIALIZE(m_bit_field_struct) +
         FAILED_TO_VALUE_INITIALIZE(m_bit_field_struct_array[0]) +
         FAILED_TO_VALUE_INITIALIZE(m_bit_field_struct_array[1]) +
@@ -817,6 +849,8 @@
       FAILED_TO_VALUE_INITIALIZE(function_ptr_struct()) +
       FAILED_TO_VALUE_INITIALIZE(member_function_ptr_type()) +
       FAILED_TO_VALUE_INITIALIZE(member_function_ptr_struct()) +
+ FAILED_TO_VALUE_INITIALIZE(ptr_to_member_type()) +
+ FAILED_TO_VALUE_INITIALIZE(ptr_to_member_struct()) +
       FAILED_TO_VALUE_INITIALIZE(int_struct()) +
       FAILED_TO_VALUE_INITIALIZE(int_struct_holder()) +
       FAILED_TO_VALUE_INITIALIZE(pod_struct()) +
@@ -869,6 +903,8 @@
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<function_ptr_struct>() ) +
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<member_function_ptr_type>() ) +
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<member_function_ptr_struct>() ) +
+ FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<ptr_to_member_type>() ) +
+ FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<ptr_to_member_struct>() ) +
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<bit_field_struct>() ) +
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<int_struct>() ) +
       FAILED_TO_VALUE_INITIALIZE( heap_object_wrapper<int_struct>() ) +
@@ -971,7 +1007,7 @@
         << num_failures_of_temporaries << '+'
         << num_failures_of_heap_objects << "): "
         << total_num_failures
- << "\nDetected by boost_no_complete_value_initialization::test() revision 25."
+ << "\nDetected by boost_no_complete_value_initialization::test() revision 26."
         << std::endl;
     }
     return static_cast<int>(total_num_failures);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk