<html>
    <head>
      <base href="https://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 --- - Analyzer crash initializing field with string literal"
   href="https://llvm.org/bugs/show_bug.cgi?id=31592">31592</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Analyzer crash initializing field with string literal
          </td>
        </tr>

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

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As reported by Miklos Vajna on cfe-dev, the following code causes an assertion
failure in the static analyzer:

$ cat field_initializer.cpp 
struct S;

template <typename T> struct C {
public:
 C(const S &left_, const T &right_) : left(left_), right(right_) {}

private:
 const S &left;
 const T &right;
};

template <typename T, int N>
inline T operator+(const T &left, const char (&right)[N]) {
 return C<const char[N]>(left, right);
}

struct S {
 template <typename T> S(T &) {}

 template <typename T> S(const C<T> &) {}
};

S f() { return S("{") + "}"; }

$ clang -cc1 -analyze -analyzer-checker=core field_initializer.cpp 
'Assume' not implemented for this NonLoc
UNREACHABLE executed at
/Volumes/Data/Clangs/OpenSourceGit/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:126!
0  clang                    0x0000000105995d46 llvm::sys::RunSignalHandlers() +
86
1  clang                    0x0000000105997429 SignalHandler(int) + 361
2  libsystem_platform.dylib 0x00007fff8b56ebba _sigtramp + 26
Stack dump:
0.    Program arguments: ../build/clang-ninja/bin/clang -cc1 -analyze
-analyzer-checker=core field_initializer.cpp 
1.    <eof> parser at end of file
2.    While analyzing stack: 
    #0 C(const S &left_, char const &right_[2]) : left(left_), right(right_) {}
    #1 template<> inline S operator+<S, 2>(const S &left, const char
(&right)[2])
    #2 S f()
3.    field_initializer.cpp:5:52: Error evaluating initializer
Abort trap: 6</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>