aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js2
-rwxr-xr-xtests/runner.py19
2 files changed, 20 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 39f7867d..aee4a416 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4383,7 +4383,7 @@ LibraryManager.library = {
ptrTV -= {{{ Runtime.QUANTUM_SIZE }}};
var TI = {{{ makeGetValue('ptrTV', '0', '*') }}};
do {
- if (TI == attemptedTI) return 1;
+ if (TI == attemptedTI) return ptr;
// Go to parent class
var type_infoAddr = {{{ makeGetValue('TI', '0', '*') }}} - {{{ Runtime.QUANTUM_SIZE*2 }}};
var type_info = {{{ makeGetValue('type_infoAddr', '0', '*') }}};
diff --git a/tests/runner.py b/tests/runner.py
index 49020904..73bf67be 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1549,6 +1549,25 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
self.do_run(src, '*11,74,32,1012*\n*11*\n*22*')
def test_dynamic_cast(self):
+ src = r'''
+ #include <stdio.h>
+
+ struct Support {
+ virtual void f() {
+ printf("f()\n");
+ }
+ };
+
+ struct Derived : Support {
+ };
+
+ int main() {
+ Support * p = new Derived;
+ dynamic_cast<Derived*>(p)->f();
+ }
+ '''
+ self.do_run(src, 'f()\n')
+
src = '''
#include <stdio.h>