On Thu, Jan 23, 2020 at 07:41:11PM +0100, Tim Düsterhus wrote:
> Willy,
> 
> Am 23.01.20 um 19:17 schrieb Willy Tarreau:
> > Thanks for the test! So basically this clearly proves we respect the
> > calling convention but the compiler still complains. OK I'm seeing in
> > the mad that it's for functions "decorated" with the "alloc_size"
> > attribute. Thus in short they enforce constraints that cannot be
> > expressed with available types. This is becoming totally ridiculous.
> 
> Googling for that error message says something about the *result*
> needing to fit into ptrdiff_t and also something about negative numbers.
> 
> Maybe it is sufficient to change `nbthread` from `int` to `unsigned
> int`?

That's essentially what the cast did. Also we don't do it because I think
I remember that we used to use value -1 to mean "unspecified" during the
parsing.

> Otherwise the compiler assumes that a negative nbthread casted to
> an unsigned value becomes too large.

No, the reality is only about the possible extent of the value. By
turning it to unsigned it it would still be allowed to cover 0..2^32-1.
It turns out the compiler knows nothing about this value and just says
"if you did something wrong, it could theorically do that". That's
exactly the problem with this type of warnings, they're utter shit
because they assume the compiler knows better than the developer what
the possible range of his numbers are but the compiler doesn't even
look where the values are assigned and knows nothing, so it only relies
on types.

Anyway it's obvious that stupid gcc warnings started to appear after
gcc developers stopped using it for themselves by rewriting it in C++,
so they don't care if they piss off their users. Possibly some of them
don't even read C anymore since they don't need to :-/

Willy

Reply via email to