public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted
@ 2012-05-23 20:36 schwan@uni-mainz.de
  2012-05-24  7:21 ` [Bug c++/53464] " daniel.kruegler at googlemail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: schwan@uni-mainz.de @ 2012-05-23 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53464
           Summary: Invalid default value for non-type template parameter
                    is accepted
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: schwan@uni-mainz.de


Consider the following code:

template <int value>
struct bar
{
    static constexpr int get()
    {
        return value;
    }
};

template <typename A, int value = A::get()>
struct foo
{
};

int main()
{
    typedef foo<bar<0>> type;

    return 0;
}

It should be rejected, since A::get() is not a "converted constant expression"
as discussed in http://stackoverflow.com/questions/10721130 . I tested this
with the GCC from svn.


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
@ 2012-05-24  7:21 ` daniel.kruegler at googlemail dot com
  2012-05-24  7:58 ` schaub.johannes at googlemail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-24  7:21 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-24 07:19:28 UTC ---
I don't see why the expression A::get() should not be a converted constant
expression of the type of the template parameter, please be more specific. The
rationale provided in the referenced link does not sound convincing to me. 

In the context of the instantiation the expression A::get() is a prvalue core
constant expression of int type, thus it is a literal constant expression of
int type. It is also a converted constant expression of type int, because
A::get() already has the type int (after instantiation).


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
  2012-05-24  7:21 ` [Bug c++/53464] " daniel.kruegler at googlemail dot com
@ 2012-05-24  7:58 ` schaub.johannes at googlemail dot com
  2012-05-24 10:50 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schaub.johannes at googlemail dot com @ 2012-05-24  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

Johannes Schaub <schaub.johannes at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schaub.johannes at
                   |                            |googlemail dot com

--- Comment #2 from Johannes Schaub <schaub.johannes at googlemail dot com> 2012-05-24 07:51:09 UTC ---
Daniel, nice to meet you again :)

See my SO answer and Richard's opinion at
http://stackoverflow.com/a/10727719/34509 .


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
  2012-05-24  7:21 ` [Bug c++/53464] " daniel.kruegler at googlemail dot com
  2012-05-24  7:58 ` schaub.johannes at googlemail dot com
@ 2012-05-24 10:50 ` redi at gcc dot gnu.org
  2012-05-24 11:39 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-24 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-24 10:48:58 UTC ---
Invalid then, thanks.


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
                   ` (2 preceding siblings ...)
  2012-05-24 10:50 ` redi at gcc dot gnu.org
@ 2012-05-24 11:39 ` jakub at gcc dot gnu.org
  2012-05-24 11:51 ` paolo.carlini at oracle dot com
  2012-05-24 15:22 ` paolo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-05-24 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-24 11:27:10 UTC ---
The testcase would be nice for the testsuite though.


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
                   ` (3 preceding siblings ...)
  2012-05-24 11:39 ` jakub at gcc dot gnu.org
@ 2012-05-24 11:51 ` paolo.carlini at oracle dot com
  2012-05-24 15:22 ` paolo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-24 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-24 11:39:10 UTC ---
Later today I will add it.


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

* [Bug c++/53464] Invalid default value for non-type template parameter is accepted
  2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
                   ` (4 preceding siblings ...)
  2012-05-24 11:51 ` paolo.carlini at oracle dot com
@ 2012-05-24 15:22 ` paolo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-24 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-24 15:12:45 UTC ---
Author: paolo
Date: Thu May 24 15:12:37 2012
New Revision: 187842

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187842
Log:
2012-05-24  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53464
    * g++.dg/cpp0x/constexpr-default1.C: New.


Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-default1.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2012-05-24 15:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23 20:36 [Bug c++/53464] New: Invalid default value for non-type template parameter is accepted schwan@uni-mainz.de
2012-05-24  7:21 ` [Bug c++/53464] " daniel.kruegler at googlemail dot com
2012-05-24  7:58 ` schaub.johannes at googlemail dot com
2012-05-24 10:50 ` redi at gcc dot gnu.org
2012-05-24 11:39 ` jakub at gcc dot gnu.org
2012-05-24 11:51 ` paolo.carlini at oracle dot com
2012-05-24 15:22 ` paolo 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).