pgbench is broken on strict-C89 compilers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgbench is broken on strict-C89 compilers
Дата
Msg-id 6687.1400368515@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: pgbench is broken on strict-C89 compilers
Список pgsql-hackers
I got around to trying to build PG with the HP-supplied compiler on my
ancient HPUX box, something I do about once a release cycle to see if
we've finally broken that trailing-edge toolchain.  Things still seem
to work except for this:

cc: "pgbench.c", line 1579: error 1521: Incorrect initialization.
cc: "pgbench.c", line 1591: error 1521: Incorrect initialization.

What it's complaining about is these nonconstant initializers:
   struct ddlinfo DDLs[] = {       {           "pgbench_history",           scale >= SCALE_32BIT_THRESHOLD           ?
"tidint,bid int,aid bigint,delta int,mtime timestamp,filler char(22)"           : "tid int,bid int,aid    int,delta
int,mtimetimestamp,filler char(22)",           0       },
 

which were apparently added in commit 89d00cbe.  It appears to me that
the compiler is within its rights to refuse a nonconstant expression
for an inner initializer according to C89, though I don't see any such
restriction in C99.

We shipped this code in 9.3, and nobody's complained yet, so maybe
it's time to forget about C89 compliance.  On the other hand, minor
notational convenience seems like a pretty poor reason to move the
goalposts for C language compliance, so I'm inclined to fix this.

I'm not entirely sure what the least ugly substitute code would be.
One idea is to replace the bigint/int column types with %s and fill
in the correct type with a snprintf operation, but that's not real
attractive because it would only work for a single such column,
and the compiler could not catch any format-spec-mismatch problems.

Thoughts?
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christoph Berg
Дата:
Сообщение: Re: 9.4 beta1 crash on Debian sid/i386
Следующее
От: Andres Freund
Дата:
Сообщение: Re: pgbench is broken on strict-C89 compilers