aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample/photon.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libsample/photon.h')
-rw-r--r--tests/libsample/photon.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/libsample/photon.h b/tests/libsample/photon.h
index 18917e2..1f8483e 100644
--- a/tests/libsample/photon.h
+++ b/tests/libsample/photon.h
@@ -96,6 +96,38 @@ LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& valu
LIBSAMPLE_API int countValueIdentities(const std::list<ValueIdentity>& values);
LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values);
+// This simulates an internal error (SEGV) caused by 'noexcept' in
+// boost::intrusive_ptr before support for 'noexcept' was added. The ENTIRE
+// code below is needed to trigger the exception; it isn't seen with just a
+// 'noexcept' following a declaration.
+//
+// NOTE: For reasons that should be fairly obvious, this test unfortunately can
+// only be "run" when building in C++11 mode.
+#if __cplusplus < 201103L
+#define noexcept
+#endif
+class Pointer
+{
+public:
+ Pointer() noexcept : px(0) {}
+ Pointer(int* p) : px(p) {}
+
+ void reset() noexcept { Pointer().swap(*this); }
+
+ int* get() const noexcept { return px; }
+ int& operator*() const { return *px; }
+
+ void swap(Pointer& rhs) noexcept
+ {
+ int* tmp = px;
+ px = rhs.px;
+ rhs.px = tmp;
+ }
+
+private:
+ int* px;
+};
+
} // namespace Photon
#endif // PHOTON_H