1 // RUN: %check_clang_tidy -std=c11-or-later %s bugprone-sizeof-expression %t
2 
3 #define alignof(type_name) _Alignof(type_name)
4 extern void sink(const void *P);
5 
6 enum { BufferSize = 1024 };
7 
8 struct S {
9   long A, B, C;
10 };
11 
12 void bad4d(void) {
13   struct S Buffer[BufferSize];
14 
15   struct S *P = &Buffer[0];
16   struct S *Q = P;
17   while (Q < P + alignof(Buffer)) {
18     // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: suspicious usage of 'alignof(...)' in pointer arithmetic; this scaled value will be scaled again by the '+' operator [bugprone-sizeof-expression]
19     // CHECK-MESSAGES: :[[@LINE-2]]:16: note: '+' in pointer arithmetic internally scales with 'sizeof(struct S)' == {{[0-9]+}}
20     sink(Q++);
21   }
22 }
23