[LLVMbugs] [Bug 17622] New: Different sscanf results from clang++ and g++

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Oct 19 03:36:57 PDT 2013


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

            Bug ID: 17622
           Summary: Different sscanf results from clang++ and g++
           Product: clang
           Version: 3.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: elliottcon at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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;
}
----------------------------------------------------------------------

-- 
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/20131019/b98325d2/attachment.html>


More information about the llvm-bugs mailing list