Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-06-20 Thread Corinna Vinschen
On Jun 19 11:09, Carl Fredrik Forsberg wrote: > Hello again. > I have performed a few more tests with the program below. https://cygwin.com/ml/cygwin/2017-06/msg00032.html Please check again with the latest developer snapshots from https://cygwin.com/snapshots/ Thanks, Corinna -- Corinna Vins

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-06-19 Thread Carl Fredrik Forsberg
Hello again. I have performed a few more tests with the program below. The lrint() family of functions I tested all appear tohave problems with negative numbers. There seem to be an unsigned vs. signed integer problems. I could not find cygwin/math/lrint.c on my Cygwin installation where patche

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-06-07 Thread Corinna Vinschen
On May 24 07:33, Eric Blake wrote: > On 05/24/2017 07:00 AM, Carl Fredrik Forsberg wrote: > > type cast lrint(-1.0) = 4294967295 > > Now that's an interesting one - it may be that cygwin1.dll actually has > buggy behavior in lrint(). In the source code, cygwin/math/lrint.c is > dropping down to a

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-26 Thread Erik Bray
On Wed, May 24, 2017 at 6:57 PM, Eric Blake wrote: > On 05/24/2017 11:53 AM, Erik Bray wrote: > dropping down to assembly; it could very well be that the assembly code is incorrectly truncating things at 32 bits (where it is just fine for 32-bit Cygwin, but wrong for 64-bit): >>

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-25 Thread Steven Penny
On Thu, 25 May 2017 18:43:58, Steven Penny wrote: Uh, have you actually tried this? It doesnt do anything: $ cat alfa.c #define __USE_MINGW_ANSI_STDIO 1 #include int main() { printf("%zi %zu %llu\n", __SIZE_MAX__, __SIZE_MAX__, __SIZE_MAX__); } $ x86_64-w64-mingw3

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-25 Thread Steven Penny
On Thu, 25 May 2017 13:17:30, Eric Blake wrote: Correct. Newer gcc's -Wformat-signedness will flag the discrepency. Uh, have you actually tried this? It doesnt do anything: $ cat alfa.c #define __USE_MINGW_ANSI_STDIO 1 #include int main() { printf("%zi %zu %llu\n", __SIZE_MA

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-25 Thread Eric Blake
On 05/24/2017 06:36 PM, Steven Penny wrote: > On Wed, 24 May 2017 07:33:27, Eric Blake wrote: >> Buggy. size_t should be printed with %zi, not %i (since size_t and int >> are not necessarily the same type). > > Aren’t both wrong? By definition %i is a signed integer, and size_t is > unsigned. > S

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-25 Thread Brian Inglis
On 2017-05-24 19:31, Steven Penny wrote: > On Wed, 24 May 2017 16:36:03, Steven Penny wrote: >> Aren’t both wrong? By definition %i is a signed integer, and size_t is >> unsigned. >> So %zu or %llu would be more correct: >> http://wikipedia.org/wiki/C_data_types >> They all seem to do the job thoug

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Steven Penny
On Wed, 24 May 2017 16:36:03, Steven Penny wrote: Aren’t both wrong? By definition %i is a signed integer, and size_t is unsigned. So %zu or %llu would be more correct: http://wikipedia.org/wiki/C_data_types They all seem to do the job though: Correcting myself. Here is why you cannot use %zi

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Steven Penny
On Wed, 24 May 2017 07:33:27, Eric Blake wrote: Buggy. size_t should be printed with %zi, not %i (since size_t and int are not necessarily the same type). Aren’t both wrong? By definition %i is a signed integer, and size_t is unsigned. So %zu or %llu would be more correct: http://wikipedia.or

RE: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Carl Fredrik Forsberg
int(-1.0) = 4294967295 lrint(1.0) = 1 llrint(1.0) = 1 Via sprintf: int -1 = -1 size of long long int: 8 size of long int: 8 size of int: 4 -Original Message- From: cygwin-ow...@cygwin.com [mailto:cygwin-ow...@cygwin.com] On Behalf Of Eric Blake Sent: 24 May 2017 18:57 To: cygwin@cygwin.co

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Eric Blake
On 05/24/2017 11:53 AM, Erik Bray wrote: >>> dropping down to assembly; it could very well be that the assembly code >>> is incorrectly truncating things at 32 bits (where it is just fine for >>> 32-bit Cygwin, but wrong for 64-bit): >>> >>> long lrint (double x) >>> { >>> long retval = 0L; >>>

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Erik Bray
On Wed, May 24, 2017 at 5:55 PM, Erik Bray wrote: > On Wed, May 24, 2017 at 2:33 PM, Eric Blake wrote: >> On 05/24/2017 07:00 AM, Carl Fredrik Forsberg wrote: >>> I am experiencing problems printing long int values under cygwin64 >>> installed on a Windows 10 machine. >>> >>> Below is a test prog

Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Erik Bray
On Wed, May 24, 2017 at 2:33 PM, Eric Blake wrote: > On 05/24/2017 07:00 AM, Carl Fredrik Forsberg wrote: >> I am experiencing problems printing long int values under cygwin64 installed >> on a Windows 10 machine. >> >> Below is a test program followed by its output to demonstrate the problem. >>

bug in lrint [was: FW: Printing long int in C program under cygwin64]

2017-05-24 Thread Eric Blake
On 05/24/2017 07:00 AM, Carl Fredrik Forsberg wrote: > I am experiencing problems printing long int values under cygwin64 installed > on a Windows 10 machine. > > Below is a test program followed by its output to demonstrate the problem. > The program was initially written to demonstrate the out

FW: Printing long int in C program under cygwin64

2017-05-24 Thread Carl Fredrik Forsberg
I am experiencing problems printing long int values under cygwin64 installed on a Windows 10 machine. Below is a test program followed by its output to demonstrate the problem. The program was initially written to demonstrate the output from lrint(), and developed further to demonstrate to myse