[cfe-users] Are these bugs for the clang compilers?

Matthew Fernandez via cfe-users cfe-users at lists.llvm.org
Wed May 27 07:09:57 PDT 2020

Hi Tianyou,

I am not enough of a physicist to know what “the qualification of the ground state energy in a quantum system” means, but this does not sound like a Clang bug to me. You did not say whether `a` in your example is a float or a double, but the minimum legal values for these types are the constants FLT_MIN and DBL_MIN. There is no need to try to compute them. Exceeding the range of values representable in a type — [FLT_MIN, FLT_MAX] or [DBL_MIN, DBL_MAX] — is undefined behavior, so the compiler is free to emit anything.


> On May 26, 2020, at 20:31, Tianyou via cfe-users <cfe-users at lists.llvm.org> wrote:
> Hello everyone,
> I found some questionable behaviors in the clang compiler.
> I tried to calculate the smallest number in my machine with clang. I did it by looping as: 
> a = a / 1.73
> In g++, after 1358 loops, I found that a = 4.94066E-324, and the value of a never changes from loop 1358 till the end 1500 loop.
> It is questionable for me that a non zero real number here a = 4.94066E-324 divided by a non zero and non one real number here 1.73 will keep the same value. The phenomenon seems to the qualification of the ground state energy in a quantum system.
> Is this bug for the clang compiler?
> I tested my code with, g++ (Apple LLVM version 10.0.0, clang-1000.10.44.4) on Macintosh. I also tried a = a / 1.7, a = a / 1.77. 
> All have similar results. A ground state qualification and unchanged value of a. 
> I guess that it is related to the binary system used by the computer system. 
> Here with my codes. 
> Best wishes
> Tianyou Yi
> Postdoc researcher in National Tsing Hua University
> Best wishes
> Tianyou Yi 
> Please send me to 
> yitianyoucn at qq.com
> yitianyou9711 at gzemail.cn
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20200527/bf21a437/attachment.html>

More information about the cfe-users mailing list