[Top][All Lists]

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

Re: AC_COMPUTE_INT's arguments

From: Stepan Kasal
Subject: Re: AC_COMPUTE_INT's arguments
Date: Wed, 6 Sep 2006 15:50:47 +0200
User-agent: Mutt/

Hello Ralf,

On Mon, Sep 04, 2006 at 07:12:29PM +0200, Ralf Wildenhues wrote:
> * Stepan Kasal wrote on Mon, Sep 04, 2006 at 06:30:19PM CEST:
> > Well, it only says that `sizeof(foo) >= 0' has problems.
> Yes, but I noticed the issue with AC_CHECK_ALIGNOF as well.
> Also, see the more verbose description in
> Compiler Characteristics).  And more indication that this bug (or these
> bugs; it's not clear to me there was just one) is of different nature:

thank you for the references. They seem to indicate that the following
expressions are not recognized as being constant:

(sizeof (int)) >= 0 ? 1 : -1
(offsetof (int)) == 4 ? 1 : -1
(unsigned long) (sizeof (int)) == 4 ? 1 : -1

The trick seems to be to cast `sizeof (int)' to `long int', avoiding
any unsigned type.

That's why that if I faced a problem with

        sizeof (ptrdiff_t) <= sizeof (int)

I would try this

        (long int) sizeof (ptrdiff_t) <= (long int) sizeof (int)

because I would hope that comparison of two signed integers would be
recognized as a constant expression.

OTOH, if `sizeof (ptrdiff_t) <= sizeof (int)' is handled as
non-constant, I would be surprised if a cast help.

But I'm just guessing.

Well, we should not be held back by a bug in a compiler which no one
uses and which we cannot find...

> > Anyway, I would suggest to modify ptrdiff_max.m4 to use
> > AC_LANG_BOOL_COMPILE_IFELSE([sizeof (ptrdiff_t) <= sizeof (int)])
> > and wait for a bug report.
> I'd definitely object this suggestion.

Well, the question is whether we what to support the buggy compiler.
The current code in ptrdiff_max.m4 is
        _AC_COMPUTE_INT([sizeof (ptrdiff_t) <= sizeof (int)]

If it does not work in that compiler, then we cannot have any
regression.  (And I guess it is quite possible that the code has
never met with the old buggy compiler.)

OTOH, if it works there, then
        (sizeof (ptrdiff_t) <= sizeof (int)) >= 0
is recognized as a constant expression, and I guess that
        (sizeof (ptrdiff_t) <= sizeof (int))
is also recognized as constant in that case.

But this is not important, we can leave ptrdiff_max.m4 as it is now.


reply via email to

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