<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - z3 sort equality assertion failed on scoped enum cast to integer."
   href="https://bugs.llvm.org/show_bug.cgi?id=48226">48226</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>z3 sort equality assertion failed on scoped enum cast to integer.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>info@ustchcs.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24183" name="attach_24183" title="stack-dump">attachment 24183</a> <a href="attachment.cgi?id=24183&action=edit" title="stack-dump">[details]</a></span>
stack-dump

Test case:

(excerpted from llvm/include/llvm/Analysis/AliasAnalysis.h)

/////////////////////////////////// test.cpp //////////////////////////////

enum class ModRefInfo : unsigned char {
  /// Must is provided for completeness, but no routines will return only
  /// Must today. See definition of Must below.
  Must = 0,
  /// The access may reference the value stored in memory,
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
  MustRef = 1,
  /// The access may modify the value stored in memory,
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
  MustMod = 2,
  /// The access may reference, modify or both the value stored in memory,
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
  MustModRef = MustRef | MustMod,
  /// The access neither references nor modifies the value stored in memory.
  NoModRef = 4,
  /// The access may reference the value stored in memory.
  Ref = NoModRef | MustRef,
  /// The access may modify the value stored in memory.
  Mod = NoModRef | MustMod,
  /// The access may reference and may modify the value stored in memory.
  ModRef = Ref | Mod,
};

inline ModRefInfo intersectModRef(const ModRefInfo MRI1,
    const ModRefInfo MRI2) {
  return ModRefInfo(static_cast<int>(MRI1) & static_cast<int>(MRI2));
}

ModRefInfo getModRefInfo(const ModRefInfo MRI) {
  ModRefInfo Result = ModRefInfo::ModRef;

  Result = intersectModRef(Result, MRI);
  return Result;
}

///////////////////////////////////////////////////////////////////////////////

(llvm commit: 37c74dfe72ecf4e7def22702c5a944682a7865df)

Invocation:

clang-tidy -checks=-*,clang-analyzer-* test.cpp                               \
  --allow-enabling-analyzer-alpha-checkers                                    \
  -- -Xclang -analyzer-constraints -Xclang z3                                 \
  -Xclang -analyzer-config                                                    \
  -Xclang aggressive-binary-operation-simplification=true

Stack Dump:

clang-tidy:
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:96:
static const llvm::SMTExpr*
clang::ento::SMTConv::fromBinOp(llvm::SMTSolverRef&, const llvm::SMTExpr*
const&, clang::BinaryOperator::Opcode, const llvm::SMTExpr* const&, bool):
Assertion `*Solver->getSort(LHS) == *Solver->getSort(RHS) && "AST's must have
the same sort!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0.      Program arguments: clang-tidy -checks=-*,clang-analyzer-*
--allow-enabling-analyzer-alpha-checkers test.cpp -- -Xclang
-analyzer-constraints -Xclang z3 -Xclang -analyzer-config -Xclang
aggressive-binary-operation-simplification=true 
1.      <eof> parser at end of file
2.      While analyzing stack: 
        #0 Calling intersectModRef at line 35
        #1 Calling getModRefInfo
3.      /root/test.cpp:28:10: Error evaluating statement
4.      /root/test.cpp:28:10: Error evaluating statement
 #0 0x00007f70a1c66b43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/workdir/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:22
 #1 0x00007f70a1c66bfa PrintStackTraceSignalHandler(void*)
/workdir/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
 #2 0x00007f70a1c64bdd llvm::sys::RunSignalHandlers()
/workdir/llvm-project/llvm/lib/Support/Signals.cpp:71:20
 #3 0x00007f70a1c6658b SignalHandler(int)
/workdir/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
 #4 0x00007f70a18a6730 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
 #5 0x00007f709b1817bb raise (/lib/x86_64-linux-gnu/libc.so.6+0x377bb)
 #6 0x00007f709b16c535 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22535)
 #7 0x00007f709b16c40f (/lib/x86_64-linux-gnu/libc.so.6+0x2240f)
 #8 0x00007f709b17a102 (/lib/x86_64-linux-gnu/libc.so.6+0x30102)
 #9 0x00007f70947b7588
clang::ento::SMTConv::fromBinOp(std::shared_ptr<llvm::SMTSolver>&,
llvm::SMTExpr const* const&, clang::BinaryOperatorKind, llvm::SMTExpr const*
const&, bool)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:95:5
#10 0x00007f70947b86fe
clang::ento::SMTConv::getBinExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, llvm::SMTExpr const* const&, clang::QualType,
clang::BinaryOperatorKind, llvm::SMTExpr const* const&, clang::QualType,
clang::QualType*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:377:3
#11 0x00007f70947b8a2f
clang::ento::SMTConv::getSymBinExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, clang::ento::BinarySymExpr const*, bool*, clang::QualType*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:396:24
#12 0x00007f70947b8e67
clang::ento::SMTConv::getSymExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, clang::ento::SymExpr const*, clang::QualType*, bool*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:451:24
#13 0x00007f70947b88f7
clang::ento::SMTConv::getSymBinExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, clang::ento::BinarySymExpr const*, bool*, clang::QualType*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:391:69
#14 0x00007f70947b8e67
clang::ento::SMTConv::getSymExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, clang::ento::SymExpr const*, clang::QualType*, bool*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:451:24
#15 0x00007f70947b8ef6
clang::ento::SMTConv::getExpr(std::shared_ptr<llvm::SMTSolver>&,
clang::ASTContext&, clang::ento::SymExpr const*, clang::QualType*, bool*)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:474:3
#16 0x00007f709496945c
clang::ento::SMTConstraintManager::assumeSym(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState
const>, clang::ento::SymExpr const*, bool)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h:51:66
#17 0x00007f709495cc63
clang::ento::SimpleConstraintManager::assumeAux(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState
const>, clang::ento::NonLoc, bool)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:73:44
#18 0x00007f709495c946
clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState
const>, clang::ento::NonLoc, bool)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:46:44
#19 0x00007f709495c8c0
clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState
const>, clang::ento::DefinedSVal, bool)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:41:57
#20 0x00007f7092f348de
clang::ento::ProgramState::assume(clang::ento::DefinedOrUnknownSVal, bool)
const
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:672:60
#21 0x00007f70931a3284 (anonymous
namespace)::ConstraintBasedEQEvaluator::operator()(llvm::APSInt const&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:49:12
#22 0x00007f70931a3ef3 bool __gnu_cxx::__ops::_Iter_pred<(anonymous
namespace)::ConstraintBasedEQEvaluator>::operator()<llvm::APSInt*>(llvm::APSInt*)
/usr/include/c++/8/bits/predefined_ops.h:283:33
#23 0x00007f70931a3db8 llvm::APSInt* std::__find_if<llvm::APSInt*,
__gnu_cxx::__ops::_Iter_pred<(anonymous namespace)::ConstraintBasedEQEvaluator>
<span class="quote">>(llvm::APSInt*, llvm::APSInt*, __gnu_cxx::__ops::_Iter_pred<(anonymous</span >
namespace)::ConstraintBasedEQEvaluator>, std::random_access_iterator_tag)
/usr/include/c++/8/bits/stl_algo.h:120:4
#24 0x00007f70931a3d23 llvm::APSInt* std::__find_if<llvm::APSInt*,
__gnu_cxx::__ops::_Iter_pred<(anonymous namespace)::ConstraintBasedEQEvaluator>
<span class="quote">>(llvm::APSInt*, llvm::APSInt*, __gnu_cxx::__ops::_Iter_pred<(anonymous</span >
namespace)::ConstraintBasedEQEvaluator>)
/usr/include/c++/8/bits/stl_algo.h:161:23
#25 0x00007f70931a3bf1 llvm::APSInt* std::find_if<llvm::APSInt*, (anonymous
namespace)::ConstraintBasedEQEvaluator>(llvm::APSInt*, llvm::APSInt*,
(anonymous namespace)::ConstraintBasedEQEvaluator)
/usr/include/c++/8/bits/stl_algo.h:3930:28
#26 0x00007f70931a3b1f bool std::none_of<llvm::APSInt*, (anonymous
namespace)::ConstraintBasedEQEvaluator>(llvm::APSInt*, llvm::APSInt*,
(anonymous namespace)::ConstraintBasedEQEvaluator)
/usr/include/c++/8/bits/stl_algo.h:526:71
#27 0x00007f70931a3a01 bool std::any_of<llvm::APSInt*, (anonymous
namespace)::ConstraintBasedEQEvaluator>(llvm::APSInt*, llvm::APSInt*,
(anonymous namespace)::ConstraintBasedEQEvaluator)
/usr/include/c++/8/bits/stl_algo.h:544:51
#28 0x00007f70931a37d4 bool llvm::any_of<llvm::SmallVector<llvm::APSInt, 6u>&,
(anonymous
namespace)::ConstraintBasedEQEvaluator>(llvm::SmallVector<llvm::APSInt, 6u>&,
(anonymous namespace)::ConstraintBasedEQEvaluator)
/workdir/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1500:21
#29 0x00007f70931a366c (anonymous
namespace)::EnumCastOutOfRangeChecker::checkPreStmt(clang::CastExpr const*,
clang::ento::CheckerContext&) const
/workdir/llvm-project/clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:132:41
#30 0x00007f70931a3c4d void
clang::ento::check::PreStmt<clang::CastExpr>::_checkStmt<(anonymous
namespace)::EnumCastOutOfRangeChecker>(void*, clang::Stmt const*,
clang::ento::CheckerContext&)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/Checker.h:86:3
#31 0x00007f7094820e4a clang::ento::CheckerFn<void (clang::Stmt const*,
clang::ento::CheckerContext&)>::operator()(clang::Stmt const*,
clang::ento::CheckerContext&) const
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:73:29
#32 0x00007f709481aa94 (anonymous
namespace)::CheckStmtContext::runChecker(clang::ento::CheckerFn<void
(clang::Stmt const*, clang::ento::CheckerContext&)>, clang::ento::NodeBuilder&,
clang::ento::ExplodedNode*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:178:5
#33 0x00007f709481d796 void expandGraphWithCheckers<(anonymous
namespace)::CheckStmtContext>((anonymous namespace)::CheckStmtContext,
clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:138:5
#34 0x00007f709481ab30 clang::ento::CheckerManager::runCheckersForStmt(bool,
clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, clang::Stmt
const*, clang::ento::ExprEngine&, bool)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:192:26
#35 0x00007f70948784a3
clang::ento::CheckerManager::runCheckersForPreStmt(clang::ento::ExplodedNodeSet&,
clang::ento::ExplodedNodeSet const&, clang::Stmt const*,
clang::ento::ExprEngine&)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:253:23
#36 0x00007f7094891c61 clang::ento::ExprEngine::VisitCast(clang::CastExpr
const*, clang::Expr const*, clang::ento::ExplodedNode*,
clang::ento::ExplodedNodeSet&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:305:44
#37 0x00007f7094869bfa clang::ento::ExprEngine::Visit(clang::Stmt const*,
clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1732:25
#38 0x00007f7094865402 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*,
clang::ento::ExplodedNode*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:792:15
#39 0x00007f7094864784
clang::ento::ExprEngine::processCFGElement(clang::CFGElement,
clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:637:18
#40 0x00007f7094838628 clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock
const*, unsigned int, clang::ento::ExplodedNode*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:468:1
#41 0x00007f7094837273
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*,
clang::ProgramPoint, clang::ento::WorkListUnit const&) (.localalias.0)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:192:7
#42 0x00007f7094836f0d
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*,
unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:147:21
#43 0x00007f70943cc0e5
clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*,
unsigned int)
/workdir/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:192:34
#44 0x00007f7094356f38 (anonymous
namespace)::AnalysisConsumer::RunPathSensitiveChecks(clang::Decl*,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*,
llvm::DenseMapInfo<clang::Decl const*> >*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:703:22
#45 0x00007f7094356d62 (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*,
llvm::DenseMapInfo<clang::Decl const*> >*)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:675:5
#46 0x00007f7094355d03 (anonymous
namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:467:31
#47 0x00007f70943560fe (anonymous
namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:517:48
#48 0x00007f70943562d3 (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&)
/workdir/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:548:75
#49 0x00007f709781cf1b
clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&)
/workdir/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:291:25
#50 0x00007f70917cea9e clang::ParseAST(clang::Sema&, bool, bool)
/workdir/llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
#51 0x00007f70977e2421 clang::ASTFrontendAction::ExecuteAction()
/workdir/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1057:11
#52 0x00007f70977e1d89 clang::FrontendAction::Execute()
/workdir/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:38
#53 0x00007f709776666a
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/workdir/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:42
#54 0x00007f709fbf79b2
clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>,
clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>,
clang::DiagnosticConsumer*)
/workdir/llvm-project/clang/lib/Tooling/Tooling.cpp:410:46
#55 0x00007f709f92a666
clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&,
clang::tooling::CompilationDatabase const&,
llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool,
llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>,
clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>,
clang::DiagnosticConsumer*)
/workdir/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:550:50
#56 0x00007f709fbf7816 clang::tooling::ToolInvocation::runInvocation(char
const*, clang::driver::Compilation*,
std::shared_ptr<clang::CompilerInvocation>,
std::shared_ptr<clang::PCHContainerOperations>)
/workdir/llvm-project/clang/lib/Tooling/Tooling.cpp:385:31
#57 0x00007f709fbf7654 clang::tooling::ToolInvocation::run()
/workdir/llvm-project/clang/lib/Tooling/Tooling.cpp:370:23
#58 0x00007f709fbf8ceb
clang::tooling::ClangTool::run(clang::tooling::ToolAction*)
/workdir/llvm-project/clang/lib/Tooling/Tooling.cpp:563:11
#59 0x00007f709f92a9de
clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&,
clang::tooling::CompilationDatabase const&,
llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, llvm::StringRef)
/workdir/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:572:28
#60 0x00007f709f81e37e clang::tidy::clangTidyMain(int, char const**)
/workdir/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:453:53
#61 0x00005647eba01155 main
/workdir/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:20:47
#62 0x00007f709b16e09b __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2409b)
#63 0x00005647eba0107a _start
(/workdir/llvm-project/build/llvm/bin/clang-tidy+0x107a)
test.sh: line 9: 54012 Aborted                 clang-tidy
-checks=-*,clang-analyzer-* --allow-enabling-analyzer-alpha-checkers test.cpp
-- -Xclang -analyzer-constraints -Xclang z3 -Xclang -analyzer-config -Xclang
aggressive-binary-operation-simplification=true</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>