Make tcu::Exception noexcept copy-constructible
authorRicardo Garcia <rgarcia@igalia.com>
Wed, 7 Apr 2021 14:22:03 +0000 (16:22 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 16 Apr 2021 06:23:12 +0000 (06:23 +0000)
This avoids warnings when using clang-tidy and some IDEs while
preventing undefined behavior.

No tests should be affected by this change, as the interface for
tcu::Exception is not modified.

Components: Framework
VK-GL-CTS issue: 2872

Change-Id: I616ae2db1d28940251b6dcade2c4b3df7e1dc5f5

framework/common/tcuDefs.hpp

index c73312b..fa8ffd0 100644 (file)
@@ -55,10 +55,12 @@ public:
                                                Exception                       (const std::string& message);
        virtual                         ~Exception                      (void) throw() {}
 
-       const char*                     getMessage                      (void) const { return m_message.c_str(); }
+       const char*                     getMessage                      (void) const { return m_message.what(); }
 
 private:
-       const std::string       m_message;
+       // std::runtime_error is used here as an immutable ref-counted string.
+       // This allows the copy constructor in the class to be noexcept.
+       const std::runtime_error m_message;
 };
 
 //! Base exception class for test exceptions that affect test result