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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to