[Top][All Lists]

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

Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral

From: Bruno Haible
Subject: Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral
Date: Sun, 10 Oct 2010 14:09:25 +0200
User-agent: KMail/1.9.9

Hi Paul,
> >> Hmm, given Bruno's recent point that C89 didn't require ?: support
> >> in constant expressions
> I'm skeptical of that.  I can't find my copy of the official C89 standard,
> but the draft <http://flash-gordon.me.uk/ansi.c.txt> says that
> constant expressions can contain ?:.  In fact, the grammar in
> section 3.4 looks like this:
>          constant-expression:
>                   conditional-expression
> and until this discussion I've never heard of the claim that
> one cannot use ?: in constant expressions.

Indeed, I cannot find the references that I used on 2002-07-23 when I first
used this idiom in gettext/m4/gettext.m4.

- The book "C, A reference manual" by Harbison & Steele, section 7.11
  "Constant expressions", says: "The binary operators [...] may be used,
  as may the unary operators - ~ ! The conditional operator ? : may be used
  ... The original description of C did not mention that the operator ! is
  allowed in constant expressions, but this was obviously an oversight or
  typographical error."

- <http://www.srcf.ucam.org/~jsm28/gcc/const-exprs-issues.txt> mentions a
  couple of issues with constant expressions, but not with ? :.

Maybe I was confused about '? :' vs. the '!' issue. Maybe I tripped over a
GCC bug. But the GCC versions that were current in 2002 are outdated nowadays.
Or maybe I tripped over a vendor compiler bug.

> Given that (X ? 1 : -1) captures the concept more clearly than
> (2 * X - 1), we're better off using the former notation than
> the latter.

I agree now.


reply via email to

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