In libio/iovdprintf.c in glibc 2.36 (before 8ece45e4f586abd212d1c02d74d38ef681a45600 and the conversion to internal buffers): 58 59 _IO_FINISH (&tmpfil.file); 60 The macro casts from the first member to the outer containing struct. 92 /* Essentially ((TYPE *) THIS)->MEMBER, but avoiding the aliasing 93 violation in case THIS has a different pointer type. */ 94 #define _IO_CAST_FIELD_ACCESS(THIS, TYPE, MEMBER) \ 95 (*(_IO_MEMBER_TYPE (TYPE, MEMBER) *)(((char *) (THIS)) \ 96 + offsetof(TYPE, MEMBER))) This works but some downstream pointer provenance checking tooling raises this as an error. It really should have been '_IO_FINISH (&tmpfil)'
> This works but some downstream pointer provenance checking tooling raises > this as an error. (Out of interest, what tooling?)
(In reply to Sam James from comment #1) > > This works but some downstream pointer provenance checking tooling raises > > this as an error. > > (Out of interest, what tooling?) Coverity.
_IO_new_fdopen has a similar problem: off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
-Wstrict-aliasing=2 has many complaints as well with gcc version 14.0.1 20240214 (experimental) and -O3. I don't think all of them are real problems, but at a glance, at least some of them are.