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

[Flang] Error during macro expension of mathematical expression at compile time.

Open JDPailleux opened this issue 1 year ago • 2 comments

Hello, I encountered a problem in the Ramses project that used the macro as follows:

program test #if NVAR > 2 print *, "YES" #else print *, "NO" #endif end program When I compile with gfortran with -cpp -DNVAR=2+1+0+0, it doesn't raise an error and the mathematical expression was expand and evaluated correctly. However, with Flang, this was not the case and the macro was expanded as a string, which is not valid normally.

Issue also referenced in PR #166785

JDPailleux avatar Nov 14 '25 15:11 JDPailleux

@llvm/issue-subscribers-bug

Author: Jean-Didier PAILLEUX (JDPailleux)

Hello, I encountered a problem in the [Ramses](https://github.com/ramses-organisation/ramses/) project that used the macro as follows:

program test #if NVAR > 2 print *, "YES" #else print *, "NO" #endif end program When I compile with gfortran with -cpp -DNVAR=2+1+0+0, it doesn't raise an error and the mathematical expression was expand and evaluated correctly. However, with Flang, this was not the case and the macro was expanded as a string, which is not valid normally.

Issue also referenced in PR #166785

llvmbot avatar Nov 14 '25 15:11 llvmbot

@llvm/issue-subscribers-flang-frontend

Author: Jean-Didier PAILLEUX (JDPailleux)

Hello, I encountered a problem in the [Ramses](https://github.com/ramses-organisation/ramses/) project that used the macro as follows:

program test #if NVAR > 2 print *, "YES" #else print *, "NO" #endif end program When I compile with gfortran with -cpp -DNVAR=2+1+0+0, it doesn't raise an error and the mathematical expression was expand and evaluated correctly. However, with Flang, this was not the case and the macro was expanded as a string, which is not valid normally.

Issue also referenced in PR #166785

llvmbot avatar Nov 19 '25 17:11 llvmbot