This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] support: Add TEST_COMPARE macro


Florian Weimer wrote:
I expect that GCC will eventually warn about such tautological comparisons.  The current approach avoids such warnings.

I've found such warnings to be more trouble than they're worth, in cases like these. (Why would we want GCC to warn that it's doing an optimization? We *like* optimizations! :-) And efforts to suppress such warnings, such as using "x > 0" instead of "x < 0", typically cause the compiler to generate worse code.

If performance is not important here then I suppose it's OK. However, it's a bad habit and I don't want the habit to leak into code where performance matters.

I don't know what the context for this new macro is, and like Andreas I'm a bit puzzled as to its intended use.

The purpose is to check if two values are the same, and print them (and record a test failure) if they are not.

Why would we want to compare (say) an uintptr_t value with a pid_t value? That sounds like a typo, and I'd rather see a compile-time diagnostic for the typo. It should be easy to arrange for such a diagnostic, and then we won't have to worry about run-time sign checking or pacifying GCC about comparisons.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]