On Fri, 27 Jun 2025, Florian Weimer wrote:

> * Joseph Myers:
> 
> > On Thu, 26 Jun 2025, Richard Biener wrote:
> >
> >> The following prototypes diagnostics for conversions to/from time_t
> >> where the source/destination does not have sufficient precision for it.
> >> I've lumped this into -Wconversion for the moment and didn't bother
> >> fixing up the testcase for !ilp32 or the -Wconversion diagnostics that
> >> happen.
> >> 
> >> Would -Wtime-conversion (or -Wtime_t-conversion?) be an appropriate
> >> option?  I'd enable it with -Wconversion.
> >
> > I think such a warning should be based on an attribute on the time_t type 
> > that means "warn for implicit truncation of this type" (I'm less clear on 
> > why warnings for implicit widening conversions *to* time_t are supposed to 
> > be useful), rather than hardcoding it to be based on the time_t name.  
> > It's hardly just time_t for which a warning about such implicit truncation 
> > might be useful.
> 
> Ideally, we'd also warn about conversion to long, when long isn't
> actually uint64_t.  This way, we can diagnose potential truncation
> during 64-bit builds.

Yeah, though fun fact - time_t is 'long' on most 64bit systems ...
so you'd diagnose a conversion from long to long.  I'm not sure
how to make this work generally with the attribute idea when
not keying explicitly on 'time_t'.

Richard.

Reply via email to