[llvm-bugs] [Bug 40982] New: Crash on switch statements of non-integer types

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 6 09:28:42 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40982

            Bug ID: 40982
           Summary: Crash on switch statements of non-integer types
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: felipe.de.azevedo.piovezan at intel.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code causes a crash with an assert failure no Clang, rather than
producing a compile error:

clang::ExprResult clang::Sema::CheckConvertedConstantExpression(clang::Expr*,
clang::QualType, llvm::APSInt&, clang::Sema::CCEKind): Assertion
`T->isIntegralOrEnumerationType() && "unexpected converted const type"' failed.

Expected:

error: statement requires expression of integer type ('NOT_AN_INTEGRAL_TYPE'
invalid)
switch(Bad) {

=================================

struct NOT_AN_INTEGRAL_TYPE { };

template<typename T> struct foo 
{
  NOT_AN_INTEGRAL_TYPE Bad;
  void run(); 
}; 

template<typename T> void foo<T>::run() {
  switch(Bad) {
    case 0: break;   // Literally breaks Clang.
  } 
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190306/30fcc1d1/attachment.html>


More information about the llvm-bugs mailing list