# Timespec size compile warning

**URL:** <https://forums.sifive.com/t/timespec-size-compile-warning/4880>\
**Category:** HiFive Unmatched\
**Created:** [June 27, 2021, 2:03am UTC](https://forums.sifive.com/t/timespec-size-compile-warning/4880 "2021-06-27T02:03:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikedilger](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/mikedilger/32/1321_2.png) [@mikedilger](https://forums.sifive.com/u/mikedilger)\
**Post date:** [June 27, 2021, 2:03am UTC](https://forums.sifive.com/t/timespec-size-compile-warning/4880/1 "2021-06-27T02:03:53Z")

</div>

I’m attempting to build linux from scratch from [www.linuxfromscratch.org](http://www.linuxfromscratch.org) (which undoubtedly will find issues as that project doesn’t presently support risc-v) and I’ve been building patches for issues I encounter as I move through it. I’m now a bit stuck now since the problem I’m now encountering is pulled in via m4 somehow, and was wondering if anyone already knows about a timespec size issue, or is better than I am at tracing back m4 macros. Here’s the compile warning:

```auto
utimens.c: In function 'fdutimens':
utimens.c:383:17: warning: 'update_timespec' accessing 16 bytes in a region of size 8 [-Wstringop-overflow=]
  383 | if (ts && update_timespec (&st, &ts))
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
utimens.c:383:17: note: referencing argument 2 of type 'struct timespec **'
utimens.c:134:1: note: in a call to function 'update_timespec'
  134 | update_timespec (struct stat const *statbuf, struct timespec *ts[2])
      | ^ ~~~~~~~~~~~~~~

```

I know it’s just a warning, but it implies that there is a type size issue which could well be catastrophic. OR… it might be totally benign.

This comes up when compiling ‘gzip’ and also when compiling ‘patch’.

I should mention that I am using linux headers generated from a version of linux created the following way: (1) checkout 5.12.4 (2) apply all meta-sifive patches, (3) merge 5.12.13 (merges suprisingly cleanly), (4) apply any other patch that became necessary.

---

<div class="post-metadata">

**Author:** ![mikedilger](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/mikedilger/32/1321_2.png) [@mikedilger](https://forums.sifive.com/u/mikedilger)\
**Post date:** [June 27, 2021, 7:53am UTC](https://forums.sifive.com/t/timespec-size-compile-warning/4880/2 "2021-06-27T07:53:54Z")

</div>

At this point I’m pretty sure this is a false positive, since the system tools built seem to be working fine. Since I changed my language of choice from C to Rust back in 2014, warnings like this have become a lot more creepy-looking to me.

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [June 27, 2021, 3:16pm UTC](https://forums.sifive.com/t/timespec-size-compile-warning/4880/3 "2021-06-27T15:16:38Z")

</div>

The stringop-overflow warning is new. It looks like the code declares an array of size two, then casts away the array type to get a plain pointer, and then casts the pointer back to an array of size two. That confuses the stringop-overflow code. The code will work, but it could have cleaner type usage. And maybe the stringop-overflow code could be improved to handle this case better.
