public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115171] New: Constant evaluation of math.h functions in C++ against constexpr.functions
@ 2024-05-21  3:41 hstong at ca dot ibm.com
  2024-05-21  3:46 ` [Bug c++/115171] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: hstong at ca dot ibm.com @ 2024-05-21  3:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115171
           Summary: Constant evaluation of math.h functions in C++ against
                    constexpr.functions
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid, wrong-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

It appears GCC implements a non-conforming extension that results in failure to
compile a well-formed program. In particular,
https://wg21.link/constexpr.functions states that standard library functions
are not to be made constexpr by implementations except where the Standard
explicitly requires constexpr.

Online compiler: https://godbolt.org/z/e8x5jhPMc

### SOURCE (<stdin>):
```
//#include <math.h>
extern "C" double fmin(double, double);

template <typename T> void f(T, char (*)[fmin(T{}, T{}) ? 1 : 2] = 0);
constexpr bool f(int) { return true; }

static_assert(f(0.));
```

### COMPILER INVOCATION:
```
g++ -fsyntax-only -std=c++20 -xc++ -
```

### ACTUAL OUTPUT:
```
<stdin>:7:16: error: could not convert 'f<double>(0.0, 0)' from 'void' to
'bool'
```

### EXPECTED OUTPUT:
(Clean compile)

### COMPILER VERSION INFO (g++ -v):
```
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240520 (experimental) (GCC)
```

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

* [Bug c++/115171] Constant evaluation of math.h functions in C++ against constexpr.functions
  2024-05-21  3:41 [Bug c++/115171] New: Constant evaluation of math.h functions in C++ against constexpr.functions hstong at ca dot ibm.com
@ 2024-05-21  3:46 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-21  3:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup. we decided not to fix this issue since they become constexpr in C++23 in
the end ...

*** This bug has been marked as a duplicate of bug 102916 ***

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

end of thread, other threads:[~2024-05-21  3:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-21  3:41 [Bug c++/115171] New: Constant evaluation of math.h functions in C++ against constexpr.functions hstong at ca dot ibm.com
2024-05-21  3:46 ` [Bug c++/115171] " pinskia 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).