Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
561a43d2
Commit
561a43d2
authored
Jul 26, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PP: floating-point parsing: more stable handling of istringstream::fail
Possibly addresses #1456
parent
13803b18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
+8
-3
No files found.
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
561a43d2
...
@@ -316,16 +316,21 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
...
@@ -316,16 +316,21 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
ppToken
->
dval
=
(
double
)
wholeNumber
*
exponentValue
;
ppToken
->
dval
=
(
double
)
wholeNumber
*
exponentValue
;
}
else
{
}
else
{
// slow path
// slow path
ppToken
->
dval
=
0.0
;
strtodStream
.
clear
();
strtodStream
.
clear
();
strtodStream
.
str
(
ppToken
->
name
);
strtodStream
.
str
(
ppToken
->
name
);
strtodStream
>>
ppToken
->
dval
;
strtodStream
>>
ppToken
->
dval
;
// Assume failure combined with a large exponent was overflow, in
// an attempt to set INF. Otherwise, assume underflow, and set 0.0.
if
(
strtodStream
.
fail
())
{
if
(
strtodStream
.
fail
())
{
// Assume failure combined with a large exponent was overflow, in
// an attempt to set INF.
if
(
!
negativeExponent
&&
exponent
+
numWholeNumberDigits
>
300
)
if
(
!
negativeExponent
&&
exponent
+
numWholeNumberDigits
>
300
)
ppToken
->
i64val
=
0x7ff0000000000000
;
// +Infinity
ppToken
->
i64val
=
0x7ff0000000000000
;
// +Infinity
else
// Assume failure combined with a small exponent was overflow.
if
(
negativeExponent
&&
exponent
+
numWholeNumberDigits
>
300
)
ppToken
->
dval
=
0.0
;
ppToken
->
dval
=
0.0
;
// Unknown reason for failure. Theory is that either
// - the 0.0 is still there, or
// - something reasonable was written that is better than 0.0
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment