Skip to content

Commit

Permalink
Add test for sizeof being on the lhs in malloc call
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Oct 23, 2024
1 parent f545a08 commit fa16a53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/Gradient/Pointers.C
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ double structPointer (double x) {
// CHECK-NEXT: }

double cStyleMemoryAlloc(double x, size_t n) {
T* t = (T*)malloc(n * sizeof(T));
T* t = (T*)malloc(sizeof(T) * n);
memset(t, 0, n * sizeof(T));
t->x = x;
double* p = (double*)calloc(1, sizeof(double));
Expand All @@ -408,7 +408,7 @@ double cStyleMemoryAlloc(double x, size_t n) {
// CHECK: void cStyleMemoryAlloc_grad_0(double x, size_t n, double *_d_x) {
// CHECK-NEXT: size_t _d_n = 0UL;
// CHECK-NEXT: T *_d_t = (T *)calloc(n, sizeof(T));
// CHECK-NEXT: T *t = (T *)malloc(n * sizeof(T));
// CHECK-NEXT: T *t = (T *)malloc(sizeof(T) * n);
// CHECK-NEXT: memset(_d_t, 0, n * sizeof(T));
// CHECK-NEXT: memset(t, 0, n * sizeof(T));
// CHECK-NEXT: double _t0 = t->x;
Expand Down

0 comments on commit fa16a53

Please sign in to comment.