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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 0 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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
tl;dr: are d and f supposed to be compilable / are they constant expressions in
C?

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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641
  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 ` jakub at gcc dot gnu.org
  2024-02-07 22:19 ` jsm28 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-05 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[14 regression]             |[14 regression]
                   |postgresql-16.1 build       |postgresql-16.1 build
                   |failure with -Werror=vla in |failure with -Werror=vla in
                   |configure test              |configure test since
                   |                            |r14-8641
   Target Milestone|---                         |14.0
                 CC|                            |jakub at gcc dot gnu.org
           Priority|P3                          |P1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This boils down to
char d[(_Bool)0.5 == 1 ? 1 : -1];
char f[(_Bool)0.0 == 0 ? 1 : -1];
which started warning with r14-8641-g35de88e2ed0aa78f6e3306c8560cd6bb15ce0ffe

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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-02-07 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jsm28 at gcc dot gnu.org
   Last reconfirmed|                            |2024-02-07
     Ever confirmed|0                           |1

--- Comment #3 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Testing a patch.

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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-08  1:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:

https://gcc.gnu.org/g:bfd72bb44eca83b0db2b0bab895f27a8a44247a2

commit r14-8874-gbfd72bb44eca83b0db2b0bab895f27a8a44247a2
Author: Joseph Myers <josmyers@redhat.com>
Date:   Thu Feb 8 01:34:09 2024 +0000

    c: Fix boolean conversion of floating constant as integer constant
expression [PR113776]

    My fix for bug 111059 and bug 111911 caused a conversion of a floating
    constant to boolean to wrongly no longer be considered an integer
    constant expression, because logic to insert a NOP_EXPR in
    c_objc_common_truthvalue_conversion for an argument not an integer
    constant expression itself now took place after rather than before the
    conversion to bool.  In the specific case of casting a floating
    constant to bool, the result is an integer constant expression even
    though the argument isn't (build_c_cast deals with ensuring that casts
    to integer type of anything of floating type more complicated than a
    single floating constant don't get wrongly treated as integer constant
    expressions even if they fold to constants), so fix the logic in
    c_objc_common_truthvalue_conversion to handle that special case.

    Bootstrapped with no regressions for x86_64-pc-linux-gnu.

            PR c/113776

    gcc/c
            * c-typeck.cc (c_objc_common_truthvalue_conversion): Return an
            integer constant expression for boolean conversion of floating
            constant.

    gcc/testsuite/
            * gcc.dg/pr113776-1.c, gcc.dg/pr113776-2.c, gcc.dg/pr113776-3.c,
            gcc.dg/pr113776-4.c: New tests.

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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-02-08  1:40 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Fixed for GCC 14.

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

* [Bug c/113776] [14 regression] postgresql-16.1 build failure with -Werror=vla in configure test since r14-8641
  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
                   ` (4 preceding siblings ...)
  2024-02-08  1:40 ` jsm28 at gcc dot gnu.org
@ 2024-02-08  4:38 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-08  4:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
Thank you!

^ 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).