Open jblachly opened 4 years ago
This was caught by our unit tests. Parentheses elision in #define macro to template conversion can lead to incorrect results when dealing with pointers.
#define
This line:
#define bam_get_cigar(b) ((uint32_t*)((b)->data + (b)->core.l_qname))
Was translated by dstep to:
extern (D) auto bam_get_cigar(T)(auto ref T b) { return cast(uint*) b.data + b.core.l_qname; }
Pointer arithmetic rules cause this to give wrong result. Our original hand translation preserves parentheses, giving correct results:
extern (D) auto bam_get_cigar(bam1_t * b) { return cast(uint*) ((*b).data + (*b).core.l_qname); }
(b->data here is a ubyte *)
b->data
ubyte *
noted by @charlesgregory
This was caught by our unit tests. Parentheses elision in
#define
macro to template conversion can lead to incorrect results when dealing with pointers.This line:
Was translated by dstep to:
Pointer arithmetic rules cause this to give wrong result. Our original hand translation preserves parentheses, giving correct results:
(
b->data
here is aubyte *
)noted by @charlesgregory