public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument
@ 2012-05-02  0:00 blaffablaffa at gmail dot com
  2012-05-12 22:47 ` [Bug c++/53181] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: blaffablaffa at gmail dot com @ 2012-05-02  0:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181

             Bug #: 53181
           Summary: static_assert sees as non constant the comparison
                    between a constexpr and a template argument
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: blaffablaffa@gmail.com


Created attachment 27278
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27278
test case

As per title.
The weird is that it seems that the constexpr-ness seems to changes if the
expression inside static_assert evaluates to true (compiles, expression seen as
constexpr) or false (fails to compile, but not due to the assertion failing but
to the described error).


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

* [Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
  2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
@ 2012-05-12 22:47 ` paolo.carlini at oracle dot com
  2012-10-18 14:45 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-12 22:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-12
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-12 22:16:36 UTC ---
Confirmed.


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

* [Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
  2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
  2012-05-12 22:47 ` [Bug c++/53181] " paolo.carlini at oracle dot com
@ 2012-10-18 14:45 ` paolo.carlini at oracle dot com
  2014-11-17 20:37 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-18 14:45 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-18 14:45:00 UTC ---
In the case of wrong_string, fold_comparison (called from cp_build_binary_op
via fold_if_not_in_template) cannot fold the comparison to a constant: base0 !=
base1. Most likely the issue is that we shouldn't end up passing such pointers.


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

* [Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
  2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
  2012-05-12 22:47 ` [Bug c++/53181] " paolo.carlini at oracle dot com
  2012-10-18 14:45 ` paolo.carlini at oracle dot com
@ 2014-11-17 20:37 ` jason at gcc dot gnu.org
  2021-08-04  8:42 ` pinskia at gcc dot gnu.org
  2021-08-04 11:28 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2014-11-17 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
The difference between the namespace- and class-scope cases is that the global
declarations are known to be defined, while the static members don't have a
visible out-of-class definition, and the middle end thinks it can't assume that
two symbols defined elsewhere won't turn out to have the same address.

Adding definitions of the static members causes the two cases to get the same
result.

constexpr char Test::wrong_string[];
constexpr char Test::right_string[];

We should probably override the middle end in this case.


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

* [Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
  2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
                   ` (2 preceding siblings ...)
  2014-11-17 20:37 ` jason at gcc dot gnu.org
@ 2021-08-04  8:42 ` pinskia at gcc dot gnu.org
  2021-08-04 11:28 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2019-02-11 00:00:00         |2021-8-4

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this is dependent on which standard you use.
For C++11 and C++14, trunk is still rejecting it.
For C++17, starting in GCC 7, the code is accepted and is correct.
C++20 on trunk accepts it.

It would be interesting to see why GCC 7+ acts this way.

(In reply to Martin Sebor from comment #5)
> No change in GCC 9.

Actually there was :).

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

* [Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
  2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
                   ` (3 preceding siblings ...)
  2021-08-04  8:42 ` pinskia at gcc dot gnu.org
@ 2021-08-04 11:28 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-04 11:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC 7 accepts it in C++17 mode because of r241137

    Implement P0386R2 - C++17 inline variables

That's because an out-of-class definition is not needed in C++17, the compiler
will generate one from the in-class declaration.

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

end of thread, other threads:[~2021-08-04 11:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02  0:00 [Bug c++/53181] New: static_assert sees as non constant the comparison between a constexpr and a template argument blaffablaffa at gmail dot com
2012-05-12 22:47 ` [Bug c++/53181] " paolo.carlini at oracle dot com
2012-10-18 14:45 ` paolo.carlini at oracle dot com
2014-11-17 20:37 ` jason at gcc dot gnu.org
2021-08-04  8:42 ` pinskia at gcc dot gnu.org
2021-08-04 11:28 ` redi 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).