https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78934

            Bug ID: 78934
           Summary: long double%intmax_t errors, long double%double
                    errors.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmichae3 at yahoo dot com
  Target Milestone: ---

disk-refresh.cpp:491:44: error: invalid operands of types 'long double' and
'long double' to binary 'operator%'
  intmax_t month=(365.24224*24*60^60*1000/(std::abs(n%365.24224)/12))+1;//days
per month
                                                    ~^~~~~~~~~~~~~~~
                                                    ?
int seems to be an int-only op now. this is surely not according to spec.
the implicit type conversions should be there.

#include <cstdint>
int main(void)
intmax_t i2=2,i3=3;
long double ld4=5,ld5=5;
long double 
dresult1=i2%ld4,dresult2=ld4%i2,dresult3=ld4%ld5,dresult4=i2%i3;
intmax_t 
iresult1=i2%ld4,iresult2=ld4%i2,iresult3=ld4%ld5,iresult4=i2%i3;
//if this works, it's because the optimizer blew the code away
return 0;


the above is the invalid error message I get from gcc 6.2.0
this is basic math that's failing.

 Tue 12/27/2016 14:53:15.53 L:\projects\disk-refresh\1.1\win\test>g++
-opctop.exe pctop.cpp
pctop.cpp: In function 'int main()':
pctop.cpp:6:12: error: invalid operands of types 'intmax_t {aka long long int}'
and 'long double' to binary 'operator%'
 dresult1=i2%ld4,
          ~~^~~~
pctop.cpp:11:12: error: invalid operands of types 'intmax_t {aka long long
int}' and 'long double' to binary 'operator%'
 iresult1=i2%ld4,
          ~~^~~~

 Tue 12/27/2016 14:55:22.90 L:\projects\disk-refresh\1.1\win\test>gcc --version
gcc (i686-win32-sjlj-rev1, Built by MinGW-W64 project) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 Tue 12/27/2016 14:56:46.14 L:\projects\disk-refresh\1.1\win\test>

Reply via email to