llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[ICE] [Clang] When Macro expansion, the call chain is too long ,so that stack overflows。

Open Zhenhang1213 opened this issue 2 years ago • 4 comments

struct S
{
  S ();
  S &operator<< (const char *);
  S (const S &);
};
 
#define N1(n) << #n
#define N2(n) N1(n)
#define N3(n) N2(n##0) N2(n##1) N2(n##2) N2(n##3) N2(n##4) \
              N2(n##5) N2(n##6) N2(n##7) N2(n##8) N2(n##9)
#define N4(n) N3(n##0) N3(n##1) N3(n##2) N3(n##3) N3(n##4) \
              N3(n##5) N3(n##6) N3(n##7) N3(n##8) N3(n##9)
#define N5(n) N4(n##0) N4(n##1) N4(n##2) N4(n##3) N4(n##4) \
              N4(n##5) N4(n##6) N4(n##7) N4(n##8) N4(n##9)
#define N6(n) N5(n##0) N5(n##1)
S s = S () N6(a) N6(b);

https://godbolt.org/z/TYT3Wo818

Zhenhang1213 avatar Dec 20 '23 01:12 Zhenhang1213

@llvm/issue-subscribers-clang-frontend

Author: None (Zhenhang1213)

``` struct S { S (); S &operator<< (const char *); S (const S &); };

#define N1(n) << #n #define N2(n) N1(n) #define N3(n) N2(n##0) N2(n##1) N2(n##2) N2(n##3) N2(n##4)
N2(n##5) N2(n##6) N2(n##7) N2(n##8) N2(n##9) #define N4(n) N3(n##0) N3(n##1) N3(n##2) N3(n##3) N3(n##4)
N3(n##5) N3(n##6) N3(n##7) N3(n##8) N3(n##9) #define N5(n) N4(n##0) N4(n##1) N4(n##2) N4(n##3) N4(n##4)
N4(n##5) N4(n##6) N4(n##7) N4(n##8) N4(n##9) #define N6(n) N5(n##0) N5(n##1) S s = S () N6(a) N6(b);


https://godbolt.org/z/TYT3Wo818
</details>

llvmbot avatar Dec 20 '23 02:12 llvmbot

Confirmed, I feel like we had another one like this but I can't find it.

CC @AaronBallman @cor3ntin

shafik avatar Dec 20 '23 02:12 shafik

@Zhenhang1213: Could you please elaborate?

EugeneZelenko avatar Jul 07 '24 13:07 EugeneZelenko

Reopening because the issue still reproduces for me on trunk: https://godbolt.org/z/65nx8c4jE -- if the issue can be closed, please let us know why.

AaronBallman avatar Jul 08 '24 13:07 AaronBallman