jacob-carlborg / dstep

A tool for converting C and Objective-C headers to D modules
205 stars 37 forks source link

Operator precedence error with sizeof(void *) #251

Open finitemonkey opened 4 years ago

finitemonkey commented 4 years ago

The following line (from https://github.com/P-H-C/phc-winner-argon2/blob/master/include/argon2.h);

#define ARGON2_MAX_MEMORY_BITS ARGON2_MIN(UINT32_C(32), (sizeof(void *) * CHAR_BIT - 10 - 1))

is translated into;

enum ARGON2_MAX_MEMORY_BITS = ARGON2_MIN(UINT32_C(32), void*.sizeof * CHAR_BIT - 10 - 1);

Which results in the following error when attempting to compile;

source/argon2.d(53,60): Error: found * when expecting . following void
source/argon2.d(53,61): Error: found . when expecting identifier following void.
source/argon2.d(53,62): Error: found sizeof when expecting ,
/usr/bin/ldc2 failed with exit code 1.

Parentheses around the void* make the compiler happy again! (Presumably a size_t would do the same job here, too?)

dstep: 1.0.1-10-g0f362b8 clang: 7.0.1-8 (tags/RELEASE_701/final) Compiler: LDC - the LLVM D compiler (1.12.0), based on DMD v2.082.1 and LLVM 6.0.1