Bug #9044

Too many warnings with VC 2013

Added by Heesob Park 6 months ago. Updated 3 months ago.

[ruby-core:57981]
Status:Closed
Priority:Normal
Assignee:cruby-windows
Category:core
Target version:-
ruby -v:ruby 2.1.0dev (2013-10-23 trunk 43392) [i386-mswin32_120] Backport:1.9.3: DONE, 2.0.0: DONE

Description

While building with Visual Studio Express 2013 on Windows 7, I can see many warnings like inconsistent dll linkage and overflow in constant arithmetic.

Here is a part of warnings.

C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(73) : warning C4273: 'acosh' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(475) : see previous definition of 'acosh'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(74) : warning C4273: 'asinh' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(477) : see previous definition of 'asinh'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(75) : warning C4273: 'atanh' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(479) : see previous definition of 'atanh'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(91) : warning C4273: 'round' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(516) : see previous definition of 'round'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(113) : warning C4273: 'erf' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(486) : see previous definition of 'erf'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(114) : warning C4273: 'erfc' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(487) : see previous definition of 'erfc'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(118) : warning C4273: 'tgamma' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(524) : see previous definition of 'tgamma'
C:\work\ruby-2.1.0-r43392\include\ruby/missing.h(126) : warning C4273: 'cbrt' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : see previous definition of 'cbrt'
math.c(381) : warning C4056: overflow in floating-point constant arithmetic
math.c(463) : warning C4056: overflow in floating-point constant arithmetic
math.c(478) : warning C4273: 'log2' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(504) : see previous definition of 'log2'
math.c(523) : warning C4056: overflow in floating-point constant arithmetic
math.c(565) : warning C4056: overflow in floating-point constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(381) : warning C4756: overflow in constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(382) : warning C4756: overflow in constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(463) : warning C4756: overflow in constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(565) : warning C4756: overflow in constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(867) : warning C4756: overflow in constant arithmetic
c:\work\ruby-2.1.0-r43392\math.c(523) : warning C4756: overflow in constant arithmetic

I attached the whole nmake log.

make.log (192 KB) Heesob Park, 10/23/2013 02:57 PM

Associated revisions

Revision 43398
Added by Nobuyoshi Nakada 6 months ago

Makefile.sub: C99 mathematics functions

  • win32/Makefile.sub (config.h): VC 2013 supports C99 mathematics functions. [Bug #9044]

Revision 43407
Added by Nobuyoshi Nakada 6 months ago

Makefile.sub: C99 mathematics functions

  • win32/Makefile.sub (config.h): fix version number of runtime library. log2 needs to be defined, not only HAVE_LOG2. [Bug #9044]

Revision 43408
Added by Nobuyoshi Nakada 6 months ago

win32.h: suppress INFINITY warnings

  • include/ruby/win32.h (rbinfinityfloat): suppress overflow in constant arithmetic warnings. [Bug #9044]

History

#1 Updated by Nobuyoshi Nakada 6 months ago

Those mathematics functions and a constant have been added?

#3 Updated by Nobuyoshi Nakada 6 months ago

Thank you.

I'm not sure how INFINITY is defined, any negative INFINITY constant is defined?

#4 Updated by Heesob Park 6 months ago

Here is a part of math.h

#ifndef HUGEENUF
#define HUGEENUF 1e+300 /* HUGEENUFHUGEENUF must overflow */
#endif /
HUGEENUF */

#define INFINITY ((float)(HUGEENUF * HUGEENUF)) /* causes warning C4756: overflow in constant arithmetic (by design) */
#define HUGEVALD ((double)INFINITY)
#define HUGE
VALF ((float)INFINITY)
#define HUGE_VALL ((long double)INFINITY)
#define NAN ((float)(INFINITY * 0.0F))

#5 Updated by Nobuyoshi Nakada 6 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43398.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Makefile.sub: C99 mathematics functions

  • win32/Makefile.sub (config.h): VC 2013 supports C99 mathematics functions. [Bug #9044]

#6 Updated by Nobuyoshi Nakada 6 months ago

  • Category set to core
  • Status changed from Closed to Assigned
  • Assignee set to cruby-windows
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED

"by design"!?

#7 Updated by Nobuyoshi Nakada 6 months ago

  • % Done changed from 100 to 50

#8 Updated by Nobuyoshi Nakada 6 months ago

=begin
Does this suppress (({INFINITY})) warnings?

diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 979e73b..5d04e9c 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -355,6 +355,20 @@ extern FILE *rbw32fsopen(const char *, const char *, int);
#endif

#include
+
+#if defined MSCVER && MSCVER >= 1800 && defined INFINITY
+#pragma warning(push)
+#pragma warning(disable:4756)
+static inline float
+rbinfinity(void)
+{
+ return INFINITY;
+}
+#pragma warning(pop)
+#undef INFINITY
+#define INFINITY rb
infinity
+#endif
+
#if !defined MINGW32 || defined _NOISOCEXT
#ifndef isnan
#define isnan(x) _isnan(x)
=end

#9 Updated by Heesob Park 6 months ago

The revision 43398 has a bug.

!if $(RTVER) >= 1200
should be
!if $(RT
VER) >= 120

And the above path has a bug.

#define INFINITY rbinfinity
should be
#define INFINITY rb
infinity()

After applying revision 43398 and the above patch, only one warning remains.

math.c(482) : warning C4273: 'log2' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(504) : see previous definition of 'log2'

The line 504 of math.h is
CRTIMP double _cdecl log2(In double _X);

#10 Updated by Nobuyoshi Nakada 6 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 50 to 100

This issue was solved with changeset r43407.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Makefile.sub: C99 mathematics functions

  • win32/Makefile.sub (config.h): fix version number of runtime library. log2 needs to be defined, not only HAVE_LOG2. [Bug #9044]

#11 Updated by Tomoyuki Chikanaga 5 months ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3: REQUIRED, 2.0.0: DONE

r43398, r43407, r43408, r43417 are backported to ruby20_0 at r43648.

#12 Updated by Usaku NAKAMURA 3 months ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: DONE to 1.9.3: DONE, 2.0.0: DONE

backported into ruby19_3 at r44743.

Also available in: Atom PDF