public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108205] New: ICE following "unused parameter" in precondition
@ 2022-12-23  4:32 webrown.cpp at gmail dot com
  0 siblings, 0 replies; only message in thread
From: webrown.cpp at gmail dot com @ 2022-12-23  4:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108205
           Summary: ICE following "unused parameter" in precondition
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: webrown.cpp at gmail dot com
  Target Milestone: ---

Using (Homebrew GCC HEAD-37c2d99) 13.0.0 20221213 (experimental)
and compiling via:
  g++-HEAD -std=c++23 -fmodules-ts -fcontracts -pedantic-errors \
    -O0 -Wall -Wextra -Werror -Wpedantic \
    -fno-builtin -fconcepts-diagnostics-depth=2
on an x86 MacBook Pro.

This code compiles:

[[nodiscard]] constexpr int
  quotient( double x, double y ) noexcept
{
  [[assume (y != 0.0)]];
  return int(x / y);
}

The same code also compiles as a module:

export module test;
export [[nodiscard]] constexpr int
  quotient( double x, double y ) noexcept
{
  [[assume (y != 0.0)]];
  return int(x / y);
}

But reformulating the assumption as a precondition causes issues.
First, this code is diagnosed with "unused parameter 'x'", which
seems misleading:

[[nodiscard]] constexpr int
  quotient( double x, double y ) noexcept
  [[ pre: y != 0.0 ]]
{
  return int(x / y);
}

Second, when the above is compiled as a module, the compiler 
additionally segfaults:

export module test;
export [[nodiscard]] constexpr int
  quotient( double x, double y ) noexcept
  [[ pre: y != 0.0 ]]
{
  return int(x / y);
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-23  4:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23  4:32 [Bug c++/108205] New: ICE following "unused parameter" in precondition webrown.cpp at gmail dot com

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