This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add testcase for PR59250


The PR was fixed by Jakub in r205283, this patch merely adds a
testcase for it.  Passed ubsan testsuite for -m32/-m64.

Ok for trunk?

2013-11-25  Marek Polacek  <polacek@redhat.com>

testsuite/
	* g++.dg/ubsan/pr59250.C: New test.

--- gcc/testsuite/g++.dg/ubsan/pr59250.C.mp3	2013-11-25 10:43:24.797315678 +0100
+++ gcc/testsuite/g++.dg/ubsan/pr59250.C	2013-11-25 10:41:24.859817636 +0100
@@ -0,0 +1,34 @@
+// PR sanitizer/59250
+// { dg-do compile }
+// { dg-options "-fsanitize=undefined" }
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+
+namespace std __attribute__ ((__visibility__ ("default"))) {
+   template<typename>     class allocator;
+   template<class _CharT>     struct char_traits;
+   template<typename _CharT, typename _Traits = char_traits<_CharT>,
+            typename _Alloc = allocator<_CharT> > class basic_string;
+   typedef basic_string<char> string;
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Tp>     class new_allocator     { };
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Tp>     class allocator: public __gnu_cxx::new_allocator<_Tp>     { };
+  template<typename _CharT, typename _Traits, typename _Alloc>     class basic_string     {
+   public:
+    basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
+  };
+}
+class FileImpl { };
+class FileHandle {
+  std::string fname;
+  class FileImpl* impl;
+  FileHandle (const char* fname);
+};
+class NormalFile : public FileImpl {
+     int fd;
+};
+FileHandle::FileHandle (const char* fname) : fname(fname) {
+  impl = new NormalFile();
+}

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]