aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/conv.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-07-26 17:42:23 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-08-03 13:01:53 +0200
commitb6df113247b9f3f7c3db0e65c481dad5bcfddfb4 (patch)
tree31466a07292ad0cc289de7c23e39ba31b9e8b7c3 /libphobos/src/std/conv.d
parent64ce76d940501cb04d14a0d36752b4f93473531c (diff)
downloadgcc-b6df113247b9f3f7c3db0e65c481dad5bcfddfb4.zip
gcc-b6df113247b9f3f7c3db0e65c481dad5bcfddfb4.tar.gz
gcc-b6df113247b9f3f7c3db0e65c481dad5bcfddfb4.tar.bz2
d: Merge upstream dmd d7772a2369, phobos 5748ca43f.
In upstream dmd, the compiler front-end and run-time have been merged together into one repository. Both dmd and libdruntime now track that. D front-end changes: - Deprecated `scope(failure)' blocks that contain `return' statements. - Deprecated using integers for `version' or `debug' conditions. - Deprecated returning a discarded void value from a function. - `new' can now allocate an associative array. D runtime changes: - Added avx512f detection to core.cpuid module. Phobos changes: - Changed std.experimental.logger.core.sharedLog to return shared(Logger). gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd d7772a2369. * dmd/VERSION: Bump version to v2.100.1. * d-codegen.cc (get_frameinfo): Check whether decision to generate closure changed since semantic finished. * d-lang.cc (d_handle_option): Remove handling of -fdebug=level and -fversion=level. * decl.cc (DeclVisitor::visit (VarDeclaration *)): Generate evaluation of noreturn variable initializers before throw. * expr.cc (ExprVisitor::visit (AssignExp *)): Don't generate assignment for noreturn types, only evaluate for side effects. * lang.opt (fdebug=): Undocument -fdebug=level. (fversion=): Undocument -fversion=level. libphobos/ChangeLog: * configure: Regenerate. * configure.ac (libtool_VERSION): Update to 4:0:0. * libdruntime/MERGE: Merge upstream druntime d7772a2369. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/array/duplication.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 5748ca43f. * testsuite/libphobos.gc/nocollect.d:
Diffstat (limited to 'libphobos/src/std/conv.d')
-rw-r--r--libphobos/src/std/conv.d19
1 files changed, 16 insertions, 3 deletions
diff --git a/libphobos/src/std/conv.d b/libphobos/src/std/conv.d
index 8f6c3bf..9164e07 100644
--- a/libphobos/src/std/conv.d
+++ b/libphobos/src/std/conv.d
@@ -3419,17 +3419,20 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum
}
}
+ Target result = cast(Target) (sign ? -ldval : ldval);
+
// if overflow occurred
- enforce(ldval != real.infinity, new ConvException("Range error"));
+ import std.math : isFinite;
+ enforce(isFinite(result), new ConvException("Range error"));
advanceSource();
static if (doCount)
{
- return tuple!("data", "count")(cast (Target) (sign ? -ldval : ldval), count);
+ return tuple!("data", "count")(result, count);
}
else
{
- return cast (Target) (sign ? -ldval : ldval);
+ return result;
}
}
@@ -3785,6 +3788,16 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum
assertThrown!ConvException(parse!double(s));
}
+@safe unittest // https://issues.dlang.org/show_bug.cgi?id=22637
+{
+ import std.exception : assertThrown, assertNotThrown;
+ auto src = "9991232549867999698999493543521458974414359998784641646846435132132543645435456345634541999999999999999"
+ ~ "9999999943321231321311999231345312413646846354354354399999934153465464654646464654134135354199999999996515734999"
+ ~ "9999999320135273486741354354731567431324134999999999999999999999999999999999999999999999135411.9";
+ assertThrown!ConvException(parse!double(src));
+ static if (real.max_10_exp > 310) assertNotThrown!ConvException(parse!real(src));
+}
+
/**
Parsing one character off a range returns the first element and calls `popFront`.