[LLVMbugs] [Bug 16895] New: Inline definition of a conversion operator as a friend gives a segmentation fault

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 14 18:19:04 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16895

            Bug ID: 16895
           Summary: Inline definition of a conversion operator as a friend
                    gives a segmentation fault
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ainsaar at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following invalid code (test.cpp)...

struct S { friend operator int(){} };

... when compiled with "clang++ test.cpp", gives a segmentation fault with the
following backtrace. GCC 4.7.3 diagnoses correctly: "error: ‘operator int()’
must be a nonstatic member function". Additionally, adding "S::" after "friend"
(in an attempt to qualify the name) gives another segfault with exactly the
same backtrace, but beforehand clang errs with "test.cpp:1:22: error: no
function named 'operator int' with type 'int ()' was found in the specified
scope" and the caret pointing at "o".

test.cpp:1:19: error: must use a qualified name when declaring a conversion
operator as a friend
struct S { friend operator int(){} };
                  ^
0  libLLVM-3.3.so  0x00007fd9a34107e2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  libLLVM-3.3.so  0x00007fd9a3410639
2  libpthread.so.0 0x0000003e15410bf0
3  clang           0x00000000009641d1
clang::Parser::ParseCXXInlineMethodDef(clang::AccessSpecifier,
clang::AttributeList*, clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::VirtSpecifiers const&,
clang::FunctionDefinitionKind, clang::ActionResult<clang::Expr*, true>&) + 1089
4  clang           0x000000000091393b
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*) + 6171
5  clang           0x0000000000914a34
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) + 2100
6  clang           0x0000000000916505
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&) + 2933
7  clang           0x00000000008fceb8
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 3256
8  clang           0x00000000008f048f
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 79
9  clang           0x00000000008f0c80
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 784
10 clang           0x00000000008f216b
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 75
11 clang           0x00000000008f2a7f
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 191
12 clang           0x00000000008eb9b9 clang::ParseAST(clang::Sema&, bool, bool)
+ 361
13 clang           0x00000000006414f9 clang::FrontendAction::Execute() + 185
14 clang           0x00000000006245aa
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 282
15 clang           0x000000000060e55a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1514
16 clang           0x00000000006092e8 cc1_main(char const**, char const**, char
const*, void*) + 840
17 clang           0x00000000006082f9 main + 7385
18 libc.so.6       0x0000003e1482460d __libc_start_main + 237
19 clang           0x0000000000608e01
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.23.1 -resource-dir /usr/bin/../lib/clang/3.3
-internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.3/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/siim/prog/test -ferror-limit 19 -fmessage-length
194 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-backend-option -vectorize-loops -o /tmp/test-soYsrQ.o -x c++ test.cpp 
1.      test.cpp:1:36: current parser token '}'
2.      test.cpp:1:1: parsing struct/union/class body 'S'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-pc-linux-gnu
Thread model: posix

-- 
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/20130815/f231bda1/attachment.html>


More information about the llvm-bugs mailing list