#41597: std::remquo does not yield the proper result for the quotient Open Date: 2021-02-17 22:25 Last Update: 2021-02-24 13:24 URL for this Ticket: https://osdn.net//projects/mingw/ticket/41597 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41597 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2021-02-24 13:24 Updated by: avhaecke Comment: Reply To keith Reply To avhaecke Reply To keith I've prepared the attached tentative patch, to resolve this issue; it appears to DTRT, testing under Wine with your example values, (and a few other multiples of 90.0, for the dividend). I've also attached an updated copy of libmingwex.a, with the patch applied. Please install it, in place of your existing libmingwex.a, test, and confirm that it resolves the issue for you. Thank you for your patch (and your support). However, I cannot link with your new libmingwex.a library as it appears to have the following symbols as Undefined (U) : {{{ _impmsvcrt_realloc _impmsvcrt_free }}} Those 2 symbols do not appear in the libmingwex library that came from the installer. Okay. Then your mingwrt/w32api installation is too old; did you follow apodtele's advice, and upgrade to GCC-9.2.0? In conjunction with that, you should also be using up-to-date versions of the MinGW runtime, and W32API libraries — it simply isn't practical for me to continue backporting to those versions of the same vintage as GCC-6.3.0; the attached replacement libmingwex.a is compatible with version 5.4.x runtime libraries, (and maybe also 5.3.x), but probably not with anything older. Furthermore, if you are using a mingw-get installer which suggests that GCC-6.3.0 is the latest release, then it is still referring to the (defunct) SourceForge FRS; please refer to this mailing-list post, for advice on ensuring that you can continue to receive updates. Thank you for pointing me to the correct repository. I performed the full upgrade to GCC 9.2.0 and replaced the libmingwex.a with the one you provided. It did correct the unexpected behavior I had encountered and my specific problem i.e. quo gets the correct value after the call std::remquo(x, y, quo) when x and y are of double type. However, I had a test program for remquo that also tested the case when x and y were "long double" rather than double and it continues to yield unexpected result with the library you provided. The program is as follows : #include <iostream> #include <cmath> int main(void) { int i = 14449 ; long double numer = 90.0 ; long double demo = 90.0 ; // long double long double result = std::remquo(number, denom, &i) ; std::cout << result << " " << i << std::endl ; return 0 ; } and I get as a result (with the new library) : nan -2147483648 I do not know if this behavior is expected as the correction may be a partial patch but I wanted to bring it to your attention. Many thanks for your time. Alex --------------------------------------------------------------------- Ticket Status: Reporter: avhaecke Owner: keith Type: Issues Status: Open [Owner assigned] Priority: 5 - Medium MileStone: (None) Component: WSL Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Context : This problem was encountered with gcc on MinGW in the following version : gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0 Description : The following code : double numer = 90.1 ; double denom = 90 .0 ; int quot ; double result = std::remquo(numer, denom, ") ; std::cout << "result " << result << std::endl ; std::cout << "quot " << quot << std::endl;should yield : result 0.1 quot 1 As is expected from std::remquo, quot has a magnitude which should be congruent (modulo 2 to the nth) to the magnitude of the integral quotient of x/y, n being greater or equal than 3. However with gcc 6.3.0, on MinGW, the above instructions yield : result 0.1 quot 0 On another version of gcc (gcc 4.9.1 2014), the expected behavior is encountered. -- Ticket information of MinGW - Minimalist GNU for Windows project MinGW - Minimalist GNU for Windows Project is hosted on OSDN Project URL: https://osdn.net/projects/mingw/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/mingw/ticket/41597 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41597