summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/marshal.c b/marshal.c
index 8a3a64e..bf4e332 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1201,6 +1201,20 @@ obj_alloc_by_path(const char *path, struct load_arg *arg)
return rb_obj_alloc(klass);
}
+#if defined _MSC_VER && _MSC_VER >= 1300
+#pragma warning(push)
+#pragma warning(disable:4723)
+#endif
+static double
+div0(double x)
+{
+ double t = 0.0;
+ return x / t;
+}
+#if defined _MSC_VER && _MSC_VER >= 1300
+#pragma warning(pop)
+#endif
+
static VALUE
r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
@@ -1292,18 +1306,18 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
case TYPE_FLOAT:
{
- double d, t = 0.0;
+ double d;
VALUE str = r_bytes(arg);
const char *ptr = RSTRING_PTR(str);
if (strcmp(ptr, "nan") == 0) {
- d = t / t;
+ d = div0(0.0);
}
else if (strcmp(ptr, "inf") == 0) {
- d = 1.0 / t;
+ d = div0(+1.0);
}
else if (strcmp(ptr, "-inf") == 0) {
- d = -1.0 / t;
+ d = div0(-1.0);
}
else {
char *e;