Issue 76519
Summary [Flang][OpenMP] compilation error in Semantics
Labels flang
Assignees
Reporter jeinstei
    I was following the instructions laid out in `flang/docs/GettingStarted.md`, and finding that the ninja compile is failing due to possible dangling references in the omp Semantics, and possible also mod-file. The error is reproduced below.

I'm running an Arch variant (EndeavourOS) with `gcc (GCC) 13.2.1 20230801` on commit 04873773. 

I'm happy to try different things to handle this, but it won't happen in the next few days.

```
FAILED: tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/check-omp-structure.cpp.o 
/usr/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/data/devtools/root/build/tools/flang/lib/Semantics -I/data/devtools/root/llvm-project/flang/lib/Semantics -I/data/devtools/root/llvm-project/flang/include -I/data/devtools/root/build/tools/flang/include -I/data/devtools/root/build/include -I/data/devtools/root/llvm-project/llvm/include -isystem /data/devtools/root/llvm-project/llvm/../mlir/include -isystem /data/devtools/root/build/tools/mlir/include -isystem /data/devtools/root/build/tools/clang/include -isystem /data/devtools/root/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/check-omp-structure.cpp.o -MF tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/check-omp-structure.cpp.o.d -o tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/check-omp-structure.cpp.o -c /data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp: In member function ‘void Fortran::semantics::OmpStructureChecker::ErrIfLHSAndRHSSymbolsMatch(const Fortran::parser::Variable&, const Fortran::parser::Expr&)’:
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp:1777:19: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
 1777 |     const Symbol &varSymbol = evaluate::GetSymbolVector(*v).front();
      |                   ^~~~~~~~~
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp:1777:67: note: the temporary was destroyed at the end of the full _expression_ ‘(& Fortran::evaluate::GetSymbolVector(const A&) [with A = Expr<SomeType>; SymbolVector = std::vector<Fortran::common::Reference<const Fortran::semantics::Symbol> >]().std::vector<Fortran::common::Reference<const Fortran::semantics::Symbol> >::front())->Fortran::common::Reference<const Fortran::semantics::Symbol>::operator std::conditional_t<true, const Fortran::semantics::Symbol&, void>()’
 1777 |     const Symbol &varSymbol = evaluate::GetSymbolVector(*v).front();
      |                                                                   ^
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp: In member function ‘void Fortran::semantics::OmpStructureChecker::CheckAtomicUpdateStmt(const Fortran::parser::AssignmentStmt&)’:
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp:1923:19: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
 1923 |     const Symbol &varSymbol = evaluate::GetSymbolVector(*v).front();
      |                   ^~~~~~~~~
/data/devtools/root/llvm-project/flang/lib/Semantics/check-omp-structure.cpp:1923:67: note: the temporary was destroyed at the end of the full _expression_ ‘(& Fortran::evaluate::GetSymbolVector(const A&) [with A = Expr<SomeType>; SymbolVector = std::vector<Fortran::common::Reference<const Fortran::semantics::Symbol> >]().std::vector<Fortran::common::Reference<const Fortran::semantics::Symbol> >::front())->Fortran::common::Reference<const Fortran::semantics::Symbol>::operator std::conditional_t<true, const Fortran::semantics::Symbol&, void>()’
 1923 |     const Symbol &varSymbol = evaluate::GetSymbolVector(*v).front();
      |                                                                   ^
cc1plus: all warnings being treated as errors
[5546/7100] Building CXX object tools/flang/lib/...akeFiles/obj.FortranSemantics.dir/mod-file.cpp.o
FAILED: tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/mod-file.cpp.o 
/usr/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/data/devtools/root/build/tools/flang/lib/Semantics -I/data/devtools/root/llvm-project/flang/lib/Semantics -I/data/devtools/root/llvm-project/flang/include -I/data/devtools/root/build/tools/flang/include -I/data/devtools/root/build/include -I/data/devtools/root/llvm-project/llvm/include -isystem /data/devtools/root/llvm-project/llvm/../mlir/include -isystem /data/devtools/root/build/tools/mlir/include -isystem /data/devtools/root/build/tools/clang/include -isystem /data/devtools/root/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/mod-file.cpp.o -MF tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/mod-file.cpp.o.d -o tools/flang/lib/Semantics/CMakeFiles/obj.FortranSemantics.dir/mod-file.cpp.o -c /data/devtools/root/llvm-project/flang/lib/Semantics/mod-file.cpp
/data/devtools/root/llvm-project/flang/lib/Semantics/mod-file.cpp: In function ‘void Fortran::semantics::PutInit(llvm::raw_ostream&, const Symbol&, const MaybeExpr&, const Fortran::parser::Expr*, const std::map<const Symbol*, Fortran::parser::CharBlock>&)’:
/data/devtools/root/llvm-project/flang/lib/Semantics/mod-file.cpp:912:23: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  912 |         const Symbol &dtSym{dtConst->result().derivedTypeSpec().typeSymbol()};
      |                       ^~~~~
/data/devtools/root/llvm-project/flang/lib/Semantics/mod-file.cpp:912:75: note: the temporary was destroyed at the end of the full _expression_ ‘(& dtConst->Fortran::evaluate::Constant<Fortran::evaluate::SomeKind<Fortran::common::TypeCategory::Derived> >::<anonymous>.Fortran::evaluate::ConstantBase<Fortran::evaluate::SomeKind<Fortran::common::TypeCategory::Derived>, std::map<Fortran::common::Reference<const Fortran::semantics::Symbol>, Fortran::common::Indirection<Fortran::evaluate::Expr<Fortran::evaluate::SomeType>, true>, Fortran::evaluate::ComponentCompare> >::result().Fortran::evaluate::SomeKind<Fortran::common::TypeCategory::Derived>::derivedTypeSpec())->Fortran::semantics::DerivedTypeSpec::typeSymbol()’
  912 |         const Symbol &dtSym{dtConst->result().derivedTypeSpec().typeSymbol()};
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
cc1plus: all warnings being treated as errors
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to