No description
  • C 96.5%
  • Makefile 3.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Juhani Krekelä 33979e7d93 Get rid of casts and signed integer right shifts in runtime code
Unsigned to signed cast is implementation defined (though in practice it
has the expected 2's complement semantics on essentially every relevant
platform). However, the only reason we used one in the first place was
to take advantage of arithmetic right shift broadcasting the sign bit to
the full length of a 32-bit integer. This requires right shift of
negative numbers to be defined as arithmetic – in C it is instead UB.

The remaining unsigned-to-unsigned casts would have been all defined,
but it is easier to keep the codebase UB-free by just banning all direct
casts. Since we do want to convert between 32-bit and 64-bit integers,
introduce meri_casts.h as a way to make the intent clear and warn on any
extra unintended implicit casts at the callsite.
2026-05-23 19:16:43 +02:00
.gitignore
Makefile Use rm -f in make clean 2026-05-21 14:06:05 +02:00
Makefile.common Get rid of casts and signed integer right shifts in runtime code 2026-05-23 19:16:43 +02:00
Makefile.win
meri_bigint.c Get rid of casts and signed integer right shifts in runtime code 2026-05-23 19:16:43 +02:00
meri_bigint.h Get rid of casts and signed integer right shifts in runtime code 2026-05-23 19:16:43 +02:00
meri_casts.h Get rid of casts and signed integer right shifts in runtime code 2026-05-23 19:16:43 +02:00
meri_object.c
meri_object.h
test_bigint.c Get rid of casts and signed integer right shifts in runtime code 2026-05-23 19:16:43 +02:00
tests.c
tests.h