|
From: <sv...@va...> - 2013-09-30 21:17:37
|
Author: philippe
Date: Mon Sep 30 21:17:09 2013
New Revision: 13591
Log:
Use global vars to point at possibly leaked
Depending on the compiler or optimisation level, the blocks that
are supposed to be possibly leaked are still reachable.
=> change the pointers to be global variables,
and do the allocation in a function, not in main.
Modified:
trunk/memcheck/tests/leak_cpp_interior.cpp
trunk/memcheck/tests/leak_cpp_interior.stderr.exp
trunk/memcheck/tests/leak_cpp_interior.stderr.exp-64bit
Modified: trunk/memcheck/tests/leak_cpp_interior.cpp
==============================================================================
--- trunk/memcheck/tests/leak_cpp_interior.cpp (original)
+++ trunk/memcheck/tests/leak_cpp_interior.cpp Mon Sep 30 21:17:09 2013
@@ -65,21 +65,37 @@
}
};
-int main() {
- std::string str = "Valgrind"; // interior ptr.
- std::string str2 = str;
- MyClass *ptr = new MyClass[3]; // interior ptr.
- MyClass *ptr2 = new MyClass[0]; // "interior but exterior ptr".
- // ptr2 points after the chunk, is wrongly considered by memcheck as definitely leaked.
-
- Be *ptrBCe = new Ce; // interior ptr.
- Ae *ptrACe = new Ce; // not an interior pointer.
- B *ptrBC = new C; // interior ptr.
- A *ptrAC = new C; // not an interior pointer.
+std::string str;
+std::string str2;
+MyClass *ptr;
+MyClass *ptr2;
+Be *ptrBCe;
+Ae *ptrACe;
+B *ptrBC;
+A *ptrAC;
+
+
+void doit(void)
+{
+ str = "Valgrind"; // interior ptr.
+ str2 = str;
+ ptr = new MyClass[3]; // interior ptr.
+ ptr2 = new MyClass[0]; // "interior but exterior ptr".
+ // ptr2 points after the chunk, is wrongly considered by memcheck as definitely leaked.
+
+ ptrBCe = new Ce; // interior ptr.
+ ptrACe = new Ce; // not an interior pointer.
+ ptrBC = new C; // interior ptr.
+ ptrAC = new C; // not an interior pointer.
+
+
+ str2 += " rocks (str2)\n"; // interior ptr.
+}
- str2 += " rocks (str2)\n"; // interior ptr.
+int main() {
+ doit();
VALGRIND_MONITOR_COMMAND("v.set log_output");
fprintf(stderr, "VALGRIND_DO_LEAK_CHECK\n");
Modified: trunk/memcheck/tests/leak_cpp_interior.stderr.exp
==============================================================================
--- trunk/memcheck/tests/leak_cpp_interior.stderr.exp (original)
+++ trunk/memcheck/tests/leak_cpp_interior.stderr.exp Mon Sep 30 21:17:09 2013
@@ -2,7 +2,8 @@
valgrind output will go to log
VALGRIND_DO_LEAK_CHECK
4 bytes in 1 blocks are definitely lost in loss record ... of ...
- by 0x........: main (leak_cpp_interior.cpp:72)
+ by 0x........: doit() (leak_cpp_interior.cpp:83)
+ by 0x........: main (leak_cpp_interior.cpp:98)
LEAK SUMMARY:
definitely lost: 4 bytes in 1 blocks
Modified: trunk/memcheck/tests/leak_cpp_interior.stderr.exp-64bit
==============================================================================
--- trunk/memcheck/tests/leak_cpp_interior.stderr.exp-64bit (original)
+++ trunk/memcheck/tests/leak_cpp_interior.stderr.exp-64bit Mon Sep 30 21:17:09 2013
@@ -2,7 +2,8 @@
valgrind output will go to log
VALGRIND_DO_LEAK_CHECK
8 bytes in 1 blocks are definitely lost in loss record ... of ...
- by 0x........: main (leak_cpp_interior.cpp:72)
+ by 0x........: doit() (leak_cpp_interior.cpp:83)
+ by 0x........: main (leak_cpp_interior.cpp:98)
LEAK SUMMARY:
definitely lost: 8 bytes in 1 blocks
|