diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/mpconfig.h | 2 | ||||
-rw-r--r-- | py/mpz.c | 7 | ||||
-rw-r--r-- | py/objint.c | 2 | ||||
-rw-r--r-- | py/runtime.c | 6 |
4 files changed, 12 insertions, 5 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 275147886c..119859a3a4 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -317,4 +317,6 @@ typedef double mp_float_t; #endif //INT_FMT // Modifier for function which doesn't return +#ifndef NORETURN #define NORETURN __attribute__((noreturn)) +#endif @@ -1092,8 +1092,11 @@ mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2) { */ mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) { - if (z1->len == 0 || z2->len == 0) - return mpz_zero(); + // braces below are required for compilation to succeed with CL, see bug report
+ // https://connect.microsoft.com/VisualStudio/feedback/details/864169/compilation-error-when-braces-are-left-out-of-single-line-if-statement
+ if (z1->len == 0 || z2->len == 0) {
+ return mpz_zero();
+ } mpz_t *gcd = mpz_gcd(z1, z2); mpz_t *quo = mpz_zero(); diff --git a/py/objint.c b/py/objint.c index c8bcb6080c..73b4c5d0be 100644 --- a/py/objint.c +++ b/py/objint.c @@ -303,7 +303,7 @@ STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) { // convert the bytes to an integer machine_uint_t value = 0; - for (const byte* buf = bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) { + for (const byte* buf = (const byte*)bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) { value = (value << 8) | *buf; } diff --git a/py/runtime.c b/py/runtime.c index a5a5bc5a4a..7a701fec57 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <string.h> #include <assert.h> +#include <alloca.h> #include "mpconfig.h" #include "nlr.h" @@ -1074,11 +1075,12 @@ import_error: uint pkg_name_len; const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); - char dot_name[pkg_name_len + 1 + qstr_len(name)]; + const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); + char *dot_name = alloca(dot_name_len); memcpy(dot_name, pkg_name, pkg_name_len); dot_name[pkg_name_len] = '.'; memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name)); - qstr dot_name_q = qstr_from_strn(dot_name, sizeof(dot_name)); + qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len); mp_obj_t args[5]; args[0] = MP_OBJ_NEW_QSTR(dot_name_q); |