public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111272] New: Truncated error messages with -std=c++23 and -std=c++26
@ 2023-09-01 20:08 pkeir at outlook dot com
  2023-09-01 20:44 ` [Bug c++/111272] [13/14 Regression] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pkeir at outlook dot com @ 2023-09-01 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111272
           Summary: Truncated error messages with -std=c++23 and
                    -std=c++26
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pkeir at outlook dot com
  Target Milestone: ---

The C++14 code below requires the `constexpr` specifier on the `ft` member
function. Compiling this with `-std=c++14`, `-std=c++17` or `-std=c++20` will
provide a helpful error message which identifies the need to add the
`constexpr` specifier to `ft`.

However, if `-std=c++23`, or `-std=c++26` are used, no message indicating the
need for `constexpr` on `ft` is displayed; and the message itself is truncated:
ending only in "...not usable as a 'constexpr' function because:".

struct Jam
{
  // constexpr  // n.b.
  int ft() { return 42; }

  constexpr
  Jam() { ft(); }
};

constexpr bool test()
{
  Jam j;
  return true;
}

static_assert(test(), "");

The full truncated error message is:

$ /opt/gcc-latest/bin/g++ -std=c++26 -c truncated-constexpr-error-gcc.cpp 
truncated-constexpr-error-gcc.cpp:16:19: error: non-constant condition for
static assertion
   16 | static_assert(test(), "");
      |               ~~~~^~
truncated-constexpr-error-gcc.cpp:16:19:   in ‘constexpr’ expansion of ‘test()’
truncated-constexpr-error-gcc.cpp:12:7: error: ‘constexpr Jam::Jam()’ called in
a constant expression
   12 |   Jam j;
      |       ^
truncated-constexpr-error-gcc.cpp:7:3: note: ‘constexpr Jam::Jam()’ is not
usable as a ‘constexpr’ function because:
    7 |   Jam() { ft(); }
      |   ^~~

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

end of thread, other threads:[~2024-01-12 19:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 20:08 [Bug c++/111272] New: Truncated error messages with -std=c++23 and -std=c++26 pkeir at outlook dot com
2023-09-01 20:44 ` [Bug c++/111272] [13/14 Regression] " mpolacek at gcc dot gnu.org
2023-09-01 22:48 ` pkeir at outlook dot com
2023-09-04 10:50 ` de34 at live dot cn
2023-09-12 18:28 ` pkeir at outlook dot com
2023-09-14 14:16 ` mpolacek at gcc dot gnu.org
2023-10-16 12:33 ` cvs-commit at gcc dot gnu.org
2023-10-16 12:35 ` mpolacek at gcc dot gnu.org
2024-01-12 18:07 ` pkeir at outlook dot com
2024-01-12 19:14 ` mpolacek 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).