oridb / mc

Myrddin Compiler
MIT License
387 stars 34 forks source link

-Werror=format-truncation= is resulting in an error in infer.c 'verifytraits' #173

Closed Earnestly closed 6 years ago

Earnestly commented 6 years ago

This may be a beign issue and I could workaround it by disabling this -Werror but it may be helpful to share.

cc -c -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-char-subscripts -g -O0 -MMD -MP -MF .deps/.d -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-char-subscripts -g -O0 -MMD -MP -MF .deps/infer.d -I../util/  infer.c

infer.c: In function 'verifytraits':
infer.c:992:37: error: '%s' directive output may be truncated writing up to 63 bytes into a region of size 62 [-Werror=format-truncation=]
    snprintf(bsrc, sizeof asrc, "\n\t%s from %s:%d", bbuf, fname(l), lnum(l));
                                     ^~              ~~~~
infer.c:992:4: note: 'snprintf' output 11 or more bytes (assuming 74) into a destination of size 64
    snprintf(bsrc, sizeof asrc, "\n\t%s from %s:%d", bbuf, fname(l), lnum(l));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oridb commented 6 years ago

Yep, that's why we default to -Werror. This is benign (at worst it truncates an error message), but I'll put in a fix.

oridb commented 6 years ago

I can't remember if I did anything, but I can't reproduce on any compiler I have. Let me know if it's still an issue.

Earnestly commented 6 years ago

The issue is still present for me.

oridb commented 6 years ago

Ok, should be fixed now. Thanks!

Earnestly commented 6 years ago

Yup, looks good now. Thanks o/