Bug 25400 - The lexer doesn't check for overflow/underflow in integer tokens
Summary: The lexer doesn't check for overflow/underflow in integer tokens
Status: RESOLVED FIXED
Alias: None
Product: poke
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-16 11:13 UTC by Jose E. Marchesi
Modified: 2022-07-11 18:40 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jose E. Marchesi 2020-01-16 11:13:25 UTC
The PKL lexer in pkl-lex.l does not check for underflow/overflow while
generating integer tokens:

  /* Note that strtol can't fail in this context.  */
  value = strtoll (yytext + offset, &end, base);

This means that large values (bigger than 64-bits) silently get
truncated:

  (poke) 99999999999999999999999999999999999
  0x7fffffffffffffffL

The solution for this is to check for underflow/overflow in the lexer
rules for both integers and offset units, and emit a warning about the
value being truncated.
Comment 1 Jose E. Marchesi 2020-03-28 09:38:57 UTC
This is fixed now.  The lexer emits an error when the specified literal overflows its type, for both integers and offsets.