Criterion icon indicating copy to clipboard operation
Criterion copied to clipboard

Error from Clang UBSan with new assertion and array type tag

Open tadd opened this issue 4 months ago • 0 comments

Hello. I've got error messages from UBSan of Clang 19

ubsan.c:8:5: runtime error: applying non-zero offset 1 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ubsan.c:8:5 

with the command clang -fsanitize=undefined ubsan.c -o ubsan -lcriterion && ./ubsan and the C source ubsan.c:

#include <criterion/criterion.h>
#include <criterion/new/assert.h>

Test(ubsan, null_ptr) {
    int a[] = { 1 };
    int b[] = { 1 };

    cr_expect(eq(int[1], a, b));
}

Is this intended, i.e., my code is wrong or compier has some limit / known problem?

Confirmed versions

I've used Criterion in Debian trixie

  • Official package libcriterion3 (2.4.1-2+b3)
  • My local build from source version 2.4.2

and confirmed the same messages with 3 Clang versions.

  • clang-17 (1:17.0.6-22+b2)
  • clang-18 (1:18.1.8-18+b1)
  • clang-19 (1:19.1.7-3+b1)

Although I've got no messages with 3 GCC versions.

  • gcc-12 (12.4.0-5)
  • gcc-13 (13.3.0-16)
  • gcc-14 (14.2.0-19)

tadd avatar Aug 30 '25 13:08 tadd