GCC 15.2: -Wformat-y2k warning in H5_get_localtime_str ('%c' yields only last 2 digits of year in some locales)

Open Beginner friendly
#6,876 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend

Research direction

Start in src/H5system.c at H5_get_localtime_str(), where the issue identifies strftime()'s '%c' format as the source of the GCC 15.2 warning. Check the function's existing tests or build instructions, then confirm the warning is gone after using a locale-independent format. Done when the function avoids the warning and its timestamp output uses the selected format.

Written by the indexing model from the issue text.

Description

From matio OSS-Fuzz build on Ubuntu 26.04 with GCC 15.2 (run 43303909994/job 131482003978).

The HDF5 develop branch compiled with GCC 15 emits:
src/H5system.c:243:33: warning: '%c' yields only last 2 digits of year in some locales [-Wformat-y2k]

The warning originates from H5_get_localtime_str() using strftime() with the '%c' format specifier, which is locale-dependent and may format the year with only 2 digits (Y2K issue).

Suggested fix: Replace '%c' with a locale-independent format such as '%Y-%m-%d %H:%M:%S' or '%Y%m%d' to avoid the y2k warning.

Reference: https://github.com/tbeu/matio/actions/runs/43303909994/job/131482003978

Dominant language
C
Stars
1k
Forks
372
Avg merge
2d 15h
Merged PRs (30d)
57

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HDFGroup/hdf5

All issues in HDFGroup/hdf5

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.