Skip to content

fread: avoid UB in leap year cycle calculation#7720

Open
aitap wants to merge 4 commits intomasterfrom
fix7704
Open

fread: avoid UB in leap year cycle calculation#7720
aitap wants to merge 4 commits intomasterfrom
fix7704

Conversation

@aitap
Copy link
Copy Markdown
Member

@aitap aitap commented Apr 23, 2026

Use the fix suggested by @kevinushey. Since R's Date class (and thus IDate) uses year zero, the resulting calculations agree with the system tzcode, although the Date class generally doesn't like to parse negative years:

$ TZ=UTC LC_ALL=C date -d '0004-02-29 -8year 12:00:00'
Thu Feb 29 12:00:00 UTC -004
$ R -q -s -e 'data.table::fread("-4-02-29 12:00:00\n")'
         V1       V2
     <IDat>   <char>
1: -4-02-29 12:00:00

Fixes: #7704

@aitap aitap requested a review from MichaelChirico as a code owner April 23, 2026 09:50
@aitap aitap added this to the 1.18.4 milestone Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.04%. Comparing base (8364344) to head (ac14cd5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7720      +/-   ##
==========================================
- Coverage   99.04%   99.04%   -0.01%     
==========================================
  Files          87       87              
  Lines       17037    17123      +86     
==========================================
+ Hits        16874    16959      +85     
- Misses        163      164       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fread: undefined behavior in parse_iso8601_date_core for negative years

1 participant