<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Inline definition of a conversion operator as a friend gives a segmentation fault"
   href="http://llvm.org/bugs/show_bug.cgi?id=16895">16895</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inline definition of a conversion operator as a friend gives a segmentation fault
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ainsaar@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</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>