[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
undefined behaviour in hamt.c
From: |
Bruno Haible |
Subject: |
undefined behaviour in hamt.c |
Date: |
Thu, 14 Apr 2022 01:43:24 +0200 |
Hi Marc,
When running the gnulib tests with clang's UndefinedBehaviorSanitizer, I got
this output in test-hamt.log:
../../gllib/hamt.c:685:41: runtime error: shift exponent 65 is too large for
64-bit type 'size_t' (aka 'unsigned long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../../gllib/hamt.c:685:41 in
PASS test-hamt (exit status: 0)
How to reproduce:
1. Install clang 13.
2. Set CC, CXX, CFLAGS, CXXFLAGS:
CC="clang
-fsanitize=undefined,signed-integer-overflow,shift,integer-divide-by-zero
-fno-sanitize=pointer-overflow"; \
CXX="clang++ -L/usr/lib/gcc/x86_64-linux-gnu/9 -I/usr/include/c++/9
-I/usr/include/x86_64-linux-gnu/c++/9
-fsanitize=undefined,signed-integer-overflow,shift,integer-divide-by-zero
-fno-sanitize=pointer-overflow"; \
CFLAGS="-O1 -fno-omit-frame-pointer -ggdb"; \
CXXFLAGS="-O1 -fno-omit-frame-pointer -ggdb"; \
export CC CXX CFLAGS CXXFLAGS
(The set of -I options in CXX depend on your local g++ installation.)
3. Prepare a gnulib testdir.
4. Configure, make, make check
5. Search the *.log files for 'UndefinedBehaviorSanitizer'.
Bruno
- undefined behaviour in hamt.c,
Bruno Haible <=