c++ reference is accessed via pointer dereference in 0.22

65 views
Skip to first unread message

Stephan

unread,
Feb 18, 2015, 11:16:18 AM2/18/15
to cython...@googlegroups.com
Hi, after upgrading cython from 0.20 to 0.22 my c++ code fails to compile. I stripped the problem down to the following code.

cdef extern from "<memory>" namespace "std":
    cdef cppclass shared_ptr
[T]:
       
pass

cdef
extern from "rocksdb/env.h" namespace "rocksdb":
    cdef cppclass
Logger:
       
pass

cdef
extern from "rocksdb/options.h" namespace "rocksdb":
    cdef cppclass
Options:
        shared_ptr
[Logger] info_log

cdef
extern from "rocksdb/db.h" namespace "rocksdb":
    cdef cppclass DB
:
       
const Options& GetOptions() nogil except+


cdef doit
(DB* db):
    cdef shared_ptr
[Logger] info_log = db.GetOptions().info_log

Cython 0.22 create then following c++ code

rocksdb::Options __pyx_t_1;
std
::shared_ptr<rocksdb::Logger>  __pyx_t_2;

 
/* "problem.cython":19
 *
 * cdef doit(DB* db):
 *     cdef shared_ptr[Logger] info_log = db.GetOptions().info_log             # <<<<<<<<<<<<<<
 */

 
try {
    __pyx_t_1
= __pyx_v_db->GetOptions();
 
} catch(...) {/* left out. */}

 
/* THIS GOES WRONG, because __pyx_t_1 is not a pointer. */
  __pyx_t_2
= __pyx_t_1->info_log;



As you can see cython does __pyx_t_1->info_log, however this fails during compilation. __pyx_t_1 is not a pointer ......
Cython 0.20 and 0.21 translate it correctly by using __pyx_t_1.info_log

Regards,
 Stephan

Stephan

unread,
Mar 25, 2015, 11:57:16 AM3/25/15
to cython...@googlegroups.com
A quick question. Will this be fixed by the cython team, or should I have a look into my code to find a workaround ?

Robert Bradshaw

unread,
Apr 1, 2015, 2:17:29 AM4/1/15
to cython...@googlegroups.com
Fixed: https://github.com/cython/cython/commit/b1ef20ad7b850498ca7c1dc516cf99036b6974d2
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cython-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages