<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 --- - std::string vs. string literal comparison through "expr" command fails"
   href="http://llvm.org/bugs/show_bug.cgi?id=20606">20606</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::string vs. string literal comparison through "expr" command fails
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>HP
          </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>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rdsmith@chromium.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12872" name="attach_12872" title="Source file for reproduction">attachment 12872</a> <a href="attachment.cgi?id=12872&action=edit" title="Source file for reproduction">[details]</a></span>
Source file for reproduction

If you try and execute C++ code comparing a std::string with a string literal
using "expr", you get a warning and and error:

(lldb) expr abc == "abc"
error: warning: result of comparison against a string literal is unspecified
(use strncmp instead)
error: invalid operands to binary expression ('string' (aka
'std::basic_string<char, std::char_traits<char>, std::allocator<char> >') and
'const char *')
error: 1 errors parsing expression
(lldb) 

That comparison works fine when compiled by clang++, despite the fact that the
first warning comes from the clang library
(tools/clang/lib/Sema/SemaExpr.cpp:7960 at r215285).  I poked around in that
function, and it seems like it's designed to warn against string literal
comparison in the large majority of cases (including this one).  So the
confusing thing here may be that clang++ doesn't warn about the comparison when
compiling (though I think that is the proper behavior, since std::string
explicitly defines a binary comparison operator of std::string vs. char*).

I did not explore the function where the second error comes from
(tools/clang/lib/Sema/SemaExpr.cpp:6798, same revision).

Reproduction: Compile the attached file with clang++ -g test2.cc (note the lack
of error or warning), and 

lldb a.out
break set -f test2.cc -l 8
run
expr abc == "abc"</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>