<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 --- - Different sscanf results from clang++ and g++"
href="http://llvm.org/bugs/show_bug.cgi?id=17622">17622</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Different sscanf results from clang++ and g++
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.0
</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>elliottcon@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>I'm getting different results between clang++ and g++ using sscanf().
Output and code below.
I'm running Debian 7.0 64 bit and using the debian packages for gcc and clang.
$ clang++ --version
Debian clang version 3.0-6.2 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ g++ --version
g++ (Debian 4.7.2-5) 4.7.2
$ g++ sscanf_test.cc -o sscanf_test
$ ./sscanf_test
1 successful; buf is helloworld
6 successful; pos is rnbqkb1r/ppppp1pp/7n/4Pp2/8/8/PPPP1PPP/RNBQKBNR
$ clang++ sscanf_test.cc -o sscanf_test
$ ./sscanf_test
1 successful; buf is helloworld
6 successful; pos is
----------------------------sscanf_test.cc----------------------------
#include <stdio.h>
int main(int argc, char** argv) {
char buf[128];
int successful = sscanf("helloworld", "%s", buf);
printf("%d successful; buf is %s\n", successful, buf);
char mv, pos[128], cas[4], enps[2];
int halfm = 0, fullm = 1;
successful = sscanf(
"rnbqkb1r/ppppp1pp/7n/4Pp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3",
"%s %c %s %s %d %d",
pos, &mv, cas, enps, &halfm, &fullm
);
printf("%d successful; pos is %s\n", successful, pos);
return 0;
}
----------------------------------------------------------------------</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>