Commit b1ef20ad authored by Robert Bradshaw's avatar Robert Bradshaw

Fix const ref temporaries.

parent ebb29b0e
......@@ -626,7 +626,7 @@ class FunctionState(object):
A C string referring to the variable is returned.
"""
if type.is_const:
if type.is_const and not type.is_reference:
type = type.const_base_type
if not type.is_pyobject and not type.is_memoryviewslice:
# Make manage_ref canonical, so that manage_ref will always mean
......
......@@ -4,6 +4,7 @@
template <typename T>
struct Bar {
Bar & ref() { return *this; }
const Bar & const_ref() { return *this; }
T value;
};
......
......@@ -8,6 +8,7 @@ cdef extern from "cpp_template_ref_args.h":
# bug: Bar[T] created before class fully defined
T value
Bar[T] & ref() except +
const Bar[T] & const_ref() except +
cdef cppclass Foo[T]:
Foo()
......@@ -33,8 +34,8 @@ def test_template_ref_arg(int x):
def test_template_ref_attr(int x):
"""
>>> test_template_ref_attr(4)
4
(4, 4)
"""
cdef Bar[int] bar
bar.value = x
return bar.ref().value
return bar.ref().value, bar.const_ref().value
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment