static_assert_test_fail_4.cpp 813 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // (C) Copyright Steve Cleary & John Maddock 2000.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org for most recent version including documentation.
  6. #include <boost/config.hpp>
  7. #include <boost/static_assert.hpp>
  8. //
  9. // all these tests should fail:
  10. //
  11. struct Bob
  12. {
  13. public:
  14. // Member function scope: provides access to member variables
  15. char x[4];
  16. char c;
  17. int f()
  18. {
  19. #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // broken sizeof in VC6
  20. BOOST_STATIC_ASSERT(sizeof(x) == 4);
  21. BOOST_STATIC_ASSERT(sizeof(c) == 1);
  22. BOOST_STATIC_ASSERT((sizeof(x) == sizeof(c))); // should not compile
  23. #endif
  24. return x;
  25. }
  26. };