public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113776] New: [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test
@ 2024-02-05 19:51 sjames at gcc dot gnu.org
  2024-02-05 19:51 ` [Bug c/113776] " sjames at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-05 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113776

            Bug ID: 113776
           Summary: [14 regression] postgresql-16.1 build failure with
                    -Werror=vla in configure test
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
                CC: jsm28 at gcc dot gnu.org
  Target Milestone: ---

I'm not sure if this is an issue in the configure test that postgres is using.
If so, I'll report it over there or to autoconf as appropriate.

(I think pg is doing something wrong here anyway as it's using CFLAGS it tests
for itself for all of its configure tests.)

Anyway, I originally reported this downstream in Gentoo at
https://bugs.gentoo.org/923804.

pg fails to build like:
```
pg_collation.c:46:1: error: conflicting types for ‘CollationCreate’; have
‘Oid(const char *, Oid,  Oid,  char,  _Bool,  int32,  const char *, const char
*, const char *, const char *, const char *, _Bool,  _Bool)’ {aka ‘unsigned
int(const char *, unsigned int,  unsigned int,  char,  _Bool,  int,  const char
*, const char *, const char *, const char *, const char *, _Bool,  _Bool)’}
   46 | CollationCreate(const char *collname, Oid collnamespace,
      | ^~~~~~~~~~~~~~~
In file included from pg_collation.c:25:
../../../src/include/catalog/pg_collation.h:88:17: note: previous declaration
of ‘CollationCreate’ with type ‘Oid(const char *, Oid,  Oid,  char,  bool, 
int32,  const char *, const char *, const char *, const char *, const char *,
bool,  bool)’ {aka ‘unsigned int(const char *, unsigned int,  unsigned int, 
char,  unsigned char,  int,  const char *, const char *, const char *, const
char *, const char *, unsigned char,  unsigned char)’}
   88 | extern Oid      CollationCreate(const char *collname, Oid
collnamespace,
      |                 ^~~~~~~~~~~~~~~
pg_collation.c: In function ‘CollationCreate’:
pg_collation.c:207:48: error: passing argument 3 of ‘heap_form_tuple’ from
incompatible pointer type [-Wincompatible-pointer-types]
  207 |         tup = heap_form_tuple(tupDesc, values, nulls);
      |                                                ^~~~~
      |                                                |
      |                                                _Bool *
In file included from pg_collation.c:18:
../../../src/include/access/htup_details.h:715:87: note: expected ‘bool *’ {aka
‘unsigned char *’} but argument is of type ‘_Bool *’
  715 |                                                                  Datum
*values, bool *isnull);
```

This turns out to be because of a configure test getting confused:
```

#include <stdbool.h>
#ifndef bool
"error: bool is not defined"
#endif
#ifndef false
    "error: false is not defined"
#endif
#if false
"error: false is not 0"
#endif
#ifndef true
    "error: true is not defined"
#endif
#if true != 1
    "error: true is not 1"
#endif
#ifndef __bool_true_false_are_defined
    "error: __bool_true_false_are_defined is not defined"
#endif

    struct s {
    _Bool s : 1;
    _Bool t;
} s;

char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool)0.5 == true ? 1 : -1];
/* See body of main program for 'e'.  */
char f[(_Bool)0.0 == false ? 1 : -1];
char g[true];
char h[sizeof(_Bool)];
char i[sizeof s.t];
enum { j = false, k = true, l = false * true, m = true * 256 };
/* The following fails for
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
_Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool)0 < 0 && -1 - (bool)0 < 0 ? 1 : -1];
/* Catch a bug in an HP-UX C compiler.  See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
*/
_Bool q = true;
_Bool *pq = &q;

int main() {
    bool e = &s;
    *pq |= q;
    *pq |= !q;
    /* Refer to every declared value, to avoid compiler optimizations.  */
    return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m +
            !n + !o + !p + !q + !pq);
    return 0;
}
```

With -O2 -Werror=vla, it recently started emitting:
```
<source>:30:1: warning: variably modified 'd' at file scope
   30 | char d[(bool)0.5 == true ? 1 : -1];
      | ^~~~
<source>:30:1: error: ISO C90 forbids array 'd' whose size cannot be evaluated
[-Werror=vla]
<source>:32:1: warning: variably modified 'f' at file scope
   32 | char f[(_Bool)0.0 == false ? 1 : -1];
      | ^~~~
<source>:32:1: error: ISO C90 forbids array 'f' whose size cannot be evaluated
[-Werror=vla]
cc1: some warnings being treated as errors
Compiler returned: 1
```

Is this intentional or not? GCC 13 doesn't error, nor does Clang 17.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-08  4:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 19:51 [Bug c/113776] New: [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test sjames at gcc dot gnu.org
2024-02-05 19:51 ` [Bug c/113776] " sjames at gcc dot gnu.org
2024-02-05 20:05 ` [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641 jakub at gcc dot gnu.org
2024-02-07 22:19 ` jsm28 at gcc dot gnu.org
2024-02-08  1:35 ` cvs-commit at gcc dot gnu.org
2024-02-08  1:40 ` jsm28 at gcc dot gnu.org
2024-02-08  4:38 ` sjames at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).