Issue 141409
Summary [Clang] C2Y `_Countof` weird sub-array count with multidimensional VLA
Labels clang
Assignees
Reporter fuhsnn
    This snippet:
```
#include <stdio.h>
int main(int i, char**) {
    int arr[11][++i][33][++i];

    printf("%lu\t", _Countof arr);
 printf("%lu\t", _Countof *arr);
    printf("%lu\t", _Countof **arr);
 printf("%lu\t", _Countof ***arr);
    printf("\n");
 printf("%lu\t",  sizeof arr / sizeof *arr);
    printf("%lu\t", sizeof *arr / sizeof **arr);
    printf("%lu\t",  sizeof **arr / sizeof ***arr);
    printf("%lu\t",  sizeof ***arr / sizeof ****arr);
 printf("\n\t^ here\n");
}
```
prints the following with current Godbolt trunk and clang-21 in LLVM Debian nightly:
```
11	198	33	3	
11	2	33	3	
	^ here
```
The second output looks funny, if I understand _Countof correctly it should be `2` instead of `2*33*3`.
Godbolt: https://godbolt.org/z/o1c6bWosM
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to