Source-Changes-D archive

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

Re: POINTER_ALIGNED_P (was: Re: CVS commit: src/sys)



17.02.2021 00:25:10 Valery Ushakov <uwe%stderr.spb.ru@localhost>:
> On Tue, Feb 16, 2021 at 23:54:46 +0100, Roland Illig wrote:
>> Yes, it does.  That's what the "#undef __NO_STRICT_ALIGNMENT" in the
>> test is for.
>>
>> I intentionally placed it between <sys/types.h> (which defines that
>> macro on x86 and some other platforms) and <sys/param.h> (which uses the
>> macro to switch between the boring "everything is correctly aligned" and
>> the more interesting formula suggested here.
>
> This is wrong on so many levels.  What is even the point of a test
> that doesn't test the thing as it is actually defined and used in the
> code?

The point of the test is to verify that the "complicated" formula produces correct results.  That's what several commits tried to fix.  If this test had been there from the beginning, none of the wrong formulas would have passed it.  That's the whole point.

The point of the test was intentionally not to test the actual behavior on each platform but to test the same formula, independent from the platform, and to do this, I somehow needed access to that formula.  Testing the actually used formula per platform could be added as another test.  I just wanted to avoid the obviously wrong formulas to go unnoticed in the code.  That's the point of the test, and that's exactly what it achieves.  Therefore I don't see anything wrong with it.

Roland


Home | Main Index | Thread Index | Old Index