[llvm-bugs] [Bug 46925] New: Clang crashed in clang/lib/AST/ASTContext.cpp:3115 Assertion `TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && "TypeLoc size mismatch from updating exception specification"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 30 18:50:35 PDT 2020


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

            Bug ID: 46925
           Summary: Clang crashed in clang/lib/AST/ASTContext.cpp:3115
                    Assertion `TypeLoc::getFullDataSizeForType(Updated) ==
                    TypeLoc::getFullDataSizeForType(TSInfo->getType()) &&
                    "TypeLoc size mismatch from updating exception
                    specification"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: crash-on-invalid
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, all.

So weirdly, the definition of different identifier name makes Clang-trunk
crashed. This behavior only occurs in trunk version, and other released
versions compile this well.

$cat s1.cc
unsigned g_volatile_a;
class A {
    int foo() noexcept(g_volatile_b);
};

$cat s2.cc
unsigned a;
class A {
    int foo() noexcept(b);
};


$clang++ s1.cc
s1.cc:3:24: error: use of undeclared identifier 'g_volatile_b'; did you mean
'g_volatile_a'?
    int foo() noexcept(g_volatile_b);
                       ^~~~~~~~~~~~
                       g_volatile_a
s1.cc:1:10: note: 'g_volatile_a' declared here
unsigned g_volatile_a;
         ^
s1.cc:3:24: error: argument to noexcept specifier must be a constant expression
    int foo() noexcept(g_volatile_b);
                       ^~~~~~~~~~~~
s1.cc:3:24: note: read of non-const variable 'g_volatile_a' is not allowed in a
constant expression
s1.cc:1:10: note: declared here
unsigned g_volatile_a;
         ^
clang-12:
/home/tuhaoxin/compilers/llvm-project-0730/clang/lib/AST/ASTContext.cpp:3115:
void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl *, const
FunctionProtoType::ExceptionSpecInfo &, bool): Assertion
`TypeLoc::getFullDataSizeForType(Updated) ==
TypeLoc::getFullDataSizeForType(TSInfo->getType()) && "TypeLoc size mismatch
from updating exception specification"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
s1.cc -mrelocation-model static -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/tuhaoxin/compilers/llvm-project-0730/build/lib/clang/12.0.0 -c-isystem
/usr/local/include/csmith-2.3.0 -cxx-isystem /usr/local/include/csmith-2.3.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/tuhaoxin/compilers/llvm-project-0730/build/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir
/home/tuhaoxin/gitee/run-new-scg/comparison/scg/ice-test/creduce -ferror-limit
19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/s1-07201d.o -x c++ s1.cc 
1.      <eof> parser at end of file
2.      s1.cc:2:1: parsing struct/union/class body 'A'
 #0 0x000000000275f234 PrintStackTraceSignalHandler(void*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x275f234)
 #1 0x000000000275ce2e llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x275ce2e)
 #2 0x000000000275f555 SignalHandler(int)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x275f555)
 #3 0x00007f11b16f48a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f11b0152f47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f11b01548b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f11b014442a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f11b01444a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x0000000004a23c7a
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x4a23c7a)
 #9 0x0000000004319805
clang::Sema::actOnDelayedExceptionSpecification(clang::Decl*,
clang::ExceptionSpecificationType, clang::SourceRange,
llvm::ArrayRef<clang::OpaquePtr<clang::QualType> >,
llvm::ArrayRef<clang::SourceRange>, clang::Expr*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x4319805)
#10 0x0000000003ffd948
clang::Parser::ParseLexedMethodDeclaration(clang::Parser::LateParsedMethodDeclaration&)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3ffd948)
#11 0x0000000003ffc8aa
clang::Parser::ParseLexedMethodDeclarations(clang::Parser::ParsingClass&)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3ffc8aa)
#12 0x000000000402b77e
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x402b77e)
#13 0x00000000040291f1
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x40291f1)
#14 0x0000000004009e47
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x4009e47)
#15 0x0000000003ff2d7a
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3ff2d7a)
#16 0x0000000003ff2aa5
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3ff2aa5)
#17 0x0000000003ff188f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3ff188f)
#18 0x0000000003fef8fd
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3fef8fd)
#19 0x0000000003fead2d clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x3fead2d)
#20 0x0000000002f3d8f3 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x2f3d8f3)
#21 0x0000000002ed4533
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x2ed4533)
#22 0x0000000002fe97f2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x2fe97f2)
#23 0x000000000098b578 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x98b578)
#24 0x00000000009895ec ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x9895ec)
#25 0x00000000009892a1 main
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x9892a1)
#26 0x00007f11b0135b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x00000000009862ba _start
(/home/tuhaoxin/compilers/llvm-project-0730/build/bin/clang-12+0x9862ba)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
b6635b5b15cb1c160776493a982302a854df332e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project-0730/build/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/s1-f776a1.cpp
clang-12: note: diagnostic msg: /tmp/s1-f776a1.sh
clang-12: note: diagnostic msg: 

********************

$clang++-10 s1.cc
s1.cc:3:24: error: use of undeclared identifier 'g_volatile_b'; did you mean
'g_volatile_a'?
    int foo() noexcept(g_volatile_b);
                       ^~~~~~~~~~~~
                       g_volatile_a
s1.cc:1:10: note: 'g_volatile_a' declared here
unsigned g_volatile_a;
         ^
s1.cc:3:24: error: argument to noexcept specifier must be a constant expression
    int foo() noexcept(g_volatile_b);
                       ^~~~~~~~~~~~
s1.cc:3:24: note: read of non-const variable 'g_volatile_a' is not allowed in a
constant expression
s1.cc:1:10: note: declared here
unsigned g_volatile_a;
         ^
2 errors generated.



$clang++ s2.cc
s2.cc:3:24: error: use of undeclared identifier 'b'
    int foo() noexcept(b);
                       ^
1 error generated.

My clang version is:
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
b6635b5b15cb1c160776493a982302a854df332e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project-0730/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

Thanks
Haoxin

-- 
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/20200731/310c7ed1/attachment-0001.html>


More information about the llvm-bugs mailing list