Issue 89851
Summary [Flang] flang-new crashes when NCOPIES argument of REPEAT intrinsic is not a scalar
Labels flang
Assignees
Reporter k-arrows
    Reproducible on Godbolt:
https://godbolt.org/z/xMhx4zfTf

Reproducer:
```console
$ cat test.f90
integer, parameter :: a(1) = 2
character, parameter :: b = '3'
print *, repeat(b,a)
end
```

Stack dump:
```console
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20240418/lib/clang/19 -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x00000000036a9c18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x36a9c18)
 #1 0x00000000036a758c SignalHandler(int) Signals.cpp:0:0
 #2 0x000071839ea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000071839ea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000071839ea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000071839ea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000004365d96 (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x4365d96)
 #7 0x0000000004371e51 Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>> Fortran::evaluate::FoldIntrinsicFunction<1>(Fortran::evaluate::FoldingContext&, Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x4371e51)
 #8 0x0000000004372613 Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>> Fortran::evaluate::FoldOperation<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>>(Fortran::evaluate::FoldingContext&, Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x4372613)
 #9 0x000000000436e785 Fortran::evaluate::ExpressionBase<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)3, 1>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x436e785)
#10 0x000000000436db35 Fortran::evaluate::ExpressionBase<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)3>>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)3>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x436db35)
#11 0x00000000043496ed Fortran::evaluate::ExpressionBase<Fortran::evaluate::SomeType>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x43496ed)
#12 0x0000000003f17bcb std::optional<Fortran::evaluate::Expr<Fortran::evaluate::SomeType>> Fortran::evaluate::ExpressionAnalyzer::ExprOrVariable<Fortran::parser::Expr>(Fortran::parser::Expr const&, Fortran::parser::CharBlock) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f17bcb)
#13 0x0000000003f1891f Fortran::evaluate::ExpressionAnalyzer::IterativelyAnalyzeSubexpressions(Fortran::parser::Expr const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f1891f)
#14 0x0000000003f18cb5 Fortran::evaluate::ExpressionAnalyzer::Analyze(Fortran::parser::Expr const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f18cb5)
#15 0x0000000003f2bbfc void Fortran::parser::IterativeWalk<Fortran::parser::Expr const, Fortran::semantics::ExprChecker, Fortran::parser::Expr::IntrinsicUnary const, Fortran::parser::Expr::IntrinsicBinary const>(Fortran::parser::Expr const&, Fortran::semantics::ExprChecker&) _expression_.cpp:0:0
#16 0x0000000003f2dce0 void Fortran::parser::Walk<Fortran::parser::OutputItem, Fortran::semantics::ExprChecker>(std::__cxx11::list<Fortran::parser::OutputItem, std::allocator<Fortran::parser::OutputItem>> const&, Fortran::semantics::ExprChecker&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f2dce0)
#17 0x0000000003f38081 void Fortran::parser::Walk<Fortran::semantics::ExprChecker>(std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>> const&, Fortran::semantics::ExprChecker&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f38081)
#18 0x0000000003f3947f Fortran::semantics::ExprChecker::Walk(Fortran::parser::Program const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3f3947f)
#19 0x000000000403ac5d Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x403ac5d)
#20 0x00000000036ee4e7 Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x36ee4e7)
#21 0x0000000003a18c70 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x3a18c70)
#22 0x00000000036edac5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x36edac5)
#23 0x00000000036dd407 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x36dd407)
#24 0x00000000036f3d4d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x36f3d4d)
#25 0x0000000001e7cfc8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x1e7cfc8)
#26 0x0000000001d6c7dd main (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x1d6c7dd)
#27 0x000071839ea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x000071839ea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x0000000001e7bf2e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin/flang-new+0x1e7bf2e)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 823eb1a3252dd773f9c4d92093591f1b39ac27d4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240418/bin
```

Gfortran properly rejects this program.
```console
$ gfortran test2.f90
test2.f90:3:18:

    3 | print *, repeat(b,a)
      |                  1
Error: ‘ncopies’ argument of ‘repeat’ intrinsic at (1) must be a scalar
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to