Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/sys



> Date: Sat, 5 Apr 2025 19:18:20 +0200
> From: Roland Illig <roland.illig%gmx.de@localhost>
> 
> Would it be narrow enough to add /*CONSTCOND*/ to the definition of
> ALIGNED_POINTER on i386 and amd64? Or would you consider this still too
> broad?

Might be reasonable.  But then we have a lot of predicates that might
be used in conditionals but be constant on some architectures, which
raises the question of which ones should be marked.

I wonder how many real bugs -- true positives -- lint's
constant-condition warnings find.

> The next alternative would be to mark each call to ALIGNED_POINTER as
> /*CONSTCOND*/, but that would be additional work in several places.

This reminds me of gcc's infuriating feature where carefully writing
safe bounds checks like

	unsigned n = ...;

	if (n > SIZE_MAX - sizeof(header))
		goto fail;
	x = malloc(sizeof(header) + n);

leads to -Wtype-limits failures on architectures where size_t is
64-bit and int is 32-bit, so you have to go to _extra work_ to
conditionalize the perfectly safe idiom, turning it into something
riskier just to pacify the warning, making the warning actively
harmful.


Home | Main Index | Thread Index | Old Index