Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

70 lines
3.2 KiB
C

// RUN: %clang_tysan -O0 -mllvm -tysan-outline-instrumentation=false %s -o %t && %run %t 10 >%t.out.0 2>&1
// RUN: FileCheck %s < %t.out.0
// RUN: %clang_tysan -O2 -mllvm -tysan-outline-instrumentation=false %s -o %t && %run %t 10 >%t.out 2>&1
// RUN: FileCheck %s < %t.out
// RUN: %clang_tysan -O0 -mllvm -tysan-outline-instrumentation=true %s -o %t && %run %t 10 >%t.out.0 2>&1
// RUN: FileCheck %s < %t.out.0
// RUN: %clang_tysan -O2 -mllvm -tysan-outline-instrumentation=true %s -o %t && %run %t 10 >%t.out 2>&1
// RUN: FileCheck %s < %t.out
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void __attribute__((noinline)) add_flt(float *a) {
*a += 2.0f;
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 4 at {{.*}} with type float accesses an existing object of type int
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-3]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: WRITE of size 4 at {{.*}} with type float accesses an existing object of type int
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-6]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 4 at {{.*}} with type float accesses an existing object of type long
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-9]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: WRITE of size 4 at {{.*}} with type float accesses an existing object of type long
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-12]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 4 at {{.*}} with type float accesses part of an existing object of type long that starts at offset -4
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-15]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: WRITE of size 4 at {{.*}} with type float accesses part of an existing object of type long that starts at offset -4
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-18]]
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 4 at {{.*}} with type float partially accesses an object of type short that starts at offset 2
// CHECK: {{#0 0x.* in add_flt .*basic.c:}}[[@LINE-21]]
}
int main(int argc, char *argv[]) {
int x = atoi(argv[1]);
add_flt((float *)&x);
printf("x = %d\n", x);
long y = x;
add_flt((float *)&y);
printf("y = %ld\n", y);
add_flt(((float *)&y) + 1);
printf("y = %ld\n", y);
char *mem = (char *)malloc(4 * sizeof(short));
memset(mem, 0, 4 * sizeof(short));
*(short *)(mem + 2) = x;
add_flt((float *)mem);
short s1 = *(short *)mem;
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 2 at {{.*}} with type short accesses an existing object of type float
// CHECK: {{#0 0x.* in main .*basic.c:}}[[@LINE-3]]
short s2 = *(short *)(mem + 2);
// CHECK: ERROR: TypeSanitizer: type-aliasing-violation
// CHECK: READ of size 2 at {{.*}} with type short accesses part of an existing object of type float that starts at offset -2
// CHECK: {{#0 0x.* in main .*basic.c:}}[[@LINE-3]]
printf("m[0] = %d, m[1] = %d\n", s1, s2);
free(mem);
return 0;
}
// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation