Bug 66478 - [constexpr] accepts-invalid with read of non-constant variable as discarded value
Summary: [constexpr] accepts-invalid with read of non-constant variable as discarded v...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2015-06-09 18:41 UTC by Richard Smith
Modified: 2025-03-25 17:36 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-03-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2015-06-09 18:41:42 UTC
GCC accepts this ill-formed code:

  void f(int n) { static_assert((+n, true), ""); }

This is invalid because it reads the variable 'n', whose value is not known within the constant expression.
Comment 1 Theodore.Papadopoulo 2025-03-25 17:05:27 UTC
Still accepted with
gcc version 14.2.1 20250110 (Red Hat 14.2.1-7) (GCC)