MinGW(windows下的GCC)的一个BUG:long long类型打印错误

    在WINDOWS下使用MinGW调试程序的时候,发现一个GCC的BUG。请先看下面的代码:
#include <stdio.h>

int main()
...{
    
short a = 1;
    
int b = 2;
    unsigned 
int c = 3;
    
long long d = 4;
    unsigned 
long long e = 5;
    printf(
" a=%d  b=%d  c=%u  d=%lld  e=%llu  a=%d ",
        a, b, c, d, e, a);
    printf(
"e=%llu ", e);
    
return 1;
}

     上面的代码输出什么?预想的结果应该是:
a=1
b=2
c=3
d=4
e=5
a=1
e=5

   用MinGW编译代码,运行程序,输出的结果令人惊讶:
a=1
b=2
c=3
d=4
e=0
a=5
e=5

   可见,单独输出long long类型是没有问题的,但是当long long类型出现在格式字符串的中间的时候,就会影响后面一个输出。
   我测试了微软的cl.exe和linux下的GCC,都不存在这个BUG。

    在此一记,请朋友们在WINDOWS下使用GCC的时候,注意long long类型的输出问题。

P.S 我使用的GCC版本是3.4.2, 希望更新的版本没有这个BUG。
51 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\random In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/random 66 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\stl_algo.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/stl_algo.h 62 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\algorithm from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/algorithm 7 C:\Users\admin\Documents\未命名4.cpp from C:\Users\admin\Documents\未命名4.cpp C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.tcc In instantiation of 'typename std::enable_if<std::is_class<_Sseq>::value>::type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed(_Sseq&) [with _Sseq = std::random_device; _UIntType = unsigned int; long long unsigned int __w = 32ull; long long unsigned int __n = 624ull; long long unsigned int __m = 397ull; long long unsigned int __r = 31ull; _UIntType __a = 2567483615u; long long unsigned int __u = 11ull; _UIntType __d = 4294967295u; long long unsigned int __s = 7ull; _UIntType __b = 2636928640u; long long unsigned int __t = 15ull; _UIntType __c = 4022730752u; long long unsigned int __l = 18ull; _UIntType __f = 1812433253u; typename std::enable_if<std::is_class<_Sseq>::value>::type = void]': 516 19 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.h required from 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(_Sseq&) [with _Sseq = std::random_device; <template-parameter-2-2> = void; _UIntType = unsigned int; long long unsigned int __w = 32ull; long long unsigned int __n = 624ull; long long unsigned int __m = 397ull; long long unsigned int __r = 31ull; _UIntType __a = 2567483615u; long long unsigned int __u = 11ull; _UIntType __d = 4294967295u; long long unsigned int __s = 7ull; _UIntType __b = 2636928640u; long long unsigned int __t = 15ull; _UIntType __c = 4022730752u; long long unsigned int __l = 18ull; _UIntType __f = 1812433253u]' 132 44 C:\Users\admin\Documents\未命名4.cpp required from here 360 2 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.tcc [Error] 'class std::random_device' has no member named 'generate'
最新发布
11-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值