[Top][All Lists]

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

Re: [Bug-gnulib] coding practices

From: Paul Eggert
Subject: Re: [Bug-gnulib] coding practices
Date: 14 Jan 2003 20:06:21 -0800

Bruno Haible <address@hidden> writes:

> the code as you write it is correct, but the maintainers that come
> after you are not likely to understand the subtlety of

But the code is not subtle.  It's unlikely to be rewritten in the way
that you describe; I have never seen the kind of error that you're
worrying about.  Conversely, I have seen errors masked by casts.  The
casts cause worse problems in practice.

> The problem with this idiom is that a commonly used, commonly
> correctness-preserving modification
>        type var = E;
>        return func(var);
>  <-->
>        return func(E);
> now introduces a bug.

That can introduce a bug only if func's argument type is not 'type'.
In that case the former code converts to 'type' and the latter does not.

But this is obvious.  One cannot replace one bit of code with another
bit that lacks a conversion, without checking that omitting the
conversion does not affect the code's correctness.  It's the same
reason that one cannot remove a cast willy-nilly.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]