public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class
@ 2011-10-23 15:29 trashyankes at wp dot pl
  2011-10-25  0:31 ` [Bug c++/50837] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: trashyankes at wp dot pl @ 2011-10-23 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50837
           Summary: [c++0x] static_assert and constexpr in template class
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: trashyankes@wp.pl
             Build: MinGW 4.6.0 20110210; MinGW 4.7.0 20110815


error: `'static constexpr bool z<T>::test_constexpr() [with T = int]' cannot
appear in a constant-expression`
adding `z<T>::` before `test_constexpr` fix it
------------------------------------------------------
template<class T>
struct z
{
    static constexpr bool test_constexpr()
    {
        return true;
    }
    static bool test()
    {
        static_assert(test_constexpr(), "test1");//error here
        return true;
    }
};
int main()
{
    z<int>::test();
}
------------------------------------------------------


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

* [Bug c++/50837] [c++0x] static_assert and constexpr in template class
  2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
@ 2011-10-25  0:31 ` paolo.carlini at oracle dot com
  2011-10-25  1:11 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-25  0:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-25
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-25 00:30:16 UTC ---
Non-template works, should be easy to fix.


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

* [Bug c++/50837] [c++0x] static_assert and constexpr in template class
  2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
  2011-10-25  0:31 ` [Bug c++/50837] " paolo.carlini at oracle dot com
@ 2011-10-25  1:11 ` paolo.carlini at oracle dot com
  2011-10-26  0:03 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-25  1:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-25 01:10:59 UTC ---
I can't believe it's so easy: fixes the testcase and passes the testsuite
(modulo a trivial tweak to a dg-error string):

Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 180413)
+++ cp/pt.c     (working copy)
@@ -13041,7 +13041,7 @@ tsubst_copy_and_build (tree t,
        decl = finish_id_expression (t, decl, NULL_TREE,
                                     &idk,
                                     integral_constant_expression_p,
-                                   
/*allow_non_integral_constant_expression_p=*/false,
+                                   
/*allow_non_integral_constant_expression_p=*/true,
                                     &non_integral_constant_expression_p,
                                     /*template_p=*/false,
                                     /*done=*/true,


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

* [Bug c++/50837] [c++0x] static_assert and constexpr in template class
  2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
  2011-10-25  0:31 ` [Bug c++/50837] " paolo.carlini at oracle dot com
  2011-10-25  1:11 ` paolo.carlini at oracle dot com
@ 2011-10-26  0:03 ` paolo.carlini at oracle dot com
  2011-11-10  2:45 ` paolo at gcc dot gnu.org
  2011-11-10  6:09 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-26  0:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-26 00:03:24 UTC ---
In fact, I checked that when z isn't a template, we call finish_id_expression
from cp_parser_primary_expression (instead of tsubst_copy_and_build) with the
same arguments, except allow_non_integral_constant_expression_p is true, thus
my experiment of yesterday makes a bit of sense...

Now I'm a bit concerned that template/nontype13.C becomes rejected with a very
different error message, not talking anymore about constant-expression,
instead:

nontype13.C:14:5: error: could not convert template argument
‘((Dummy<int>*)this)->Dummy<T>::evil<int>’ to ‘bool’

this change is actually the only visible regression in the testsuite.


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

* [Bug c++/50837] [c++0x] static_assert and constexpr in template class
  2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
                   ` (2 preceding siblings ...)
  2011-10-26  0:03 ` paolo.carlini at oracle dot com
@ 2011-11-10  2:45 ` paolo at gcc dot gnu.org
  2011-11-10  6:09 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-11-10  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-11-10 02:27:20 UTC ---
Author: paolo
Date: Thu Nov 10 02:27:16 2011
New Revision: 181248

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181248
Log:
/cp
2011-11-09  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50837
    * pt.c (tsubst_copy_and_build) [IDENTIFIER_NODE]: In C++11 mode
    pass allow_non_integral_constant_expression_p = true to
    finish_id_expression.

/testsuite
2011-11-09  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50837
    * g++.dg/cpp0x/static_assert5.C: New.
    * g++.dg/template/nontype13.C: Tweak.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/static_assert5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/nontype13.C


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

* [Bug c++/50837] [c++0x] static_assert and constexpr in template class
  2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
                   ` (3 preceding siblings ...)
  2011-11-10  2:45 ` paolo at gcc dot gnu.org
@ 2011-11-10  6:09 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-10  6:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-10 02:29:01 UTC ---
Fixed for 4.7.0.


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

end of thread, other threads:[~2011-11-10  2:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-23 15:29 [Bug c++/50837] New: [c++0x] static_assert and constexpr in template class trashyankes at wp dot pl
2011-10-25  0:31 ` [Bug c++/50837] " paolo.carlini at oracle dot com
2011-10-25  1:11 ` paolo.carlini at oracle dot com
2011-10-26  0:03 ` paolo.carlini at oracle dot com
2011-11-10  2:45 ` paolo at gcc dot gnu.org
2011-11-10  6:09 ` paolo.carlini at oracle 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).