public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
@ 2011-02-16 22:44 dev.lists at jessamine dot co.uk
  2011-02-16 23:12 ` [Bug c++/47774] " dev.lists at jessamine dot co.uk
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-02-16 22:44 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x] constexpr specifier on ctor not ignored when
                    template instantiation causes ctor to not satify
                    constexpr requirements
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dev.lists@jessamine.co.uk


The definition of b in the program below fails to compile due to the default
constructor for its only member not being a valid constexpr.  B itself does not
claim to be a literal type or that instances of it should be usable as
constants but g++ currently seems to enforce the constexpr nature of the ctor
of X<T> even when T causes the definition to fail to meet the constexpr
constructor requirements.

7.1.5 para 4 states:

  6  If the instantiated template specialization of a constexpr
     function template or member function of a class template would
     fail to satisfy the requirements for a constexpr function or
     constexpr constructor, that specialization is not a constexpr
     function or constexpr constructor. [Note: if the function is
     a member function it will still be const as described below.
     Implementations are encouraged to issue a warning if a
     function is rendered not constexpr by a non-dependent
     construct.  --end note]

The program below demonstrates what I think to be non-compliance with this.  It
is a reduced case (I originally came across this when attempting to instantiate
a std::array<std::pair<F,S>,N> where objects of either F or S were not usable
as constants; pair's default constructor is specified as constexpr yielding the
same problem).

template <typename T>
struct X
{
   constexpr X() : t() {}
   T t;
};

struct CanBeCompileTimeConstant     { constexpr CanBeCompileTimeConstant() {}
};
struct CannotBeCompileTimeConstant  { CannotBeCompileTimeConstant() {} };

X<CanBeCompileTimeConstant> nonconstexpr1;
X<CannotBeCompileTimeConstant> nonconstexpr2;
constexpr X<CanBeCompileTimeConstant> constexpr1;
//constexpr X<CannotBeCompileTimeConstant> constexpr2; // fails as expected

struct A
{
   X<CanBeCompileTimeConstant> mem;
};

struct B
{
   X<CannotBeCompileTimeConstant> mem;
};

A a;
B b; // fails unexpectedly: 'constexpr X<T>::X() [with T =
CannotBeCompileTimeConstant]' is not 'constexpr'


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
@ 2011-02-16 23:12 ` dev.lists at jessamine dot co.uk
  2011-02-17  8:38 ` dev.lists at jessamine dot co.uk
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-02-16 23:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-02-16 23:03:22 UTC ---
Created attachment 23369
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23369
Various declarations and constexpr specifications demonstrating problem --
runnable as sh script

Added an additional test file, runnable as sh script, which tests various
combinations of ctor specifications and member types.

Compiling with gcc version 4.6.0 20110216 (experimental) (GCC) built tonight
yields:

$ sh constexpr-ctor-templ.cpp
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T -DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘ncbool::ncbool(bool)’ is not
‘constexpr’
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘ncbool::ncbool(bool)’ is not
‘constexpr’
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T -DUSE_SYNTHESIZED_X_CTOR
constexpr-ctor-templ.cpp: In constructor ‘X<ncbool>::X()’:
constexpr-ctor-templ.cpp:100:8: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
constexpr-ctor-templ.cpp: In function ‘int main(int, char**)’:
constexpr-ctor-templ.cpp:148:14: note: synthesized method ‘X<ncbool>::X()’
first required here
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DUSE_SYNTHESIZED_X_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<ncbool>::X()’:
constexpr-ctor-templ.cpp:100:8: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
constexpr-ctor-templ.cpp:100:8: error: non-constant array initialization
constexpr-ctor-templ.cpp: In function ‘int main(int, char**)’:
constexpr-ctor-templ.cpp:148:14: note: synthesized method ‘X<ncbool>::X()’
first required here
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
--------------------------------------------
Failed 6


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
  2011-02-16 23:12 ` [Bug c++/47774] " dev.lists at jessamine dot co.uk
@ 2011-02-17  8:38 ` dev.lists at jessamine dot co.uk
  2011-02-17 11:30 ` dev.lists at jessamine dot co.uk
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-02-17  8:38 UTC (permalink / raw)
  To: gcc-bugs

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

Adam Butcher <dev.lists at jessamine dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #23369|0                           |1
        is obsolete|                            |

--- Comment #2 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-02-17 08:34:18 UTC ---
Created attachment 23373
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23373
Fix launch parameter bug with previous attachment

(In reply to comment #1)

Re: attachment 23369

Spotted a bug with options in test case.  One class of ctor specification was
used twice instead of selecting the third.
      -DUSE_SYNTHESIZED_X_CTOR \
      -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR \
  -   -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
  +   -DGIVE_X_EXPLICIT_NONCONST_CTOR

Updated attachment included revised output below.

Compiling with gcc version 4.6.0 20110217 svn trunk@170240 built this morning
yields:

+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T -DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T
-DGIVE_X_EXPLICIT_NONCONST_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘ncbool::ncbool(bool)’ is not
‘constexpr’
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DPLAIN_T_ARRAY
-DGIVE_X_EXPLICIT_NONCONST_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T -DUSE_SYNTHESIZED_X_CTOR
constexpr-ctor-templ.cpp: In constructor ‘X<ncbool>::X()’:
constexpr-ctor-templ.cpp:100:8: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
constexpr-ctor-templ.cpp: In function ‘int main(int, char**)’:
constexpr-ctor-templ.cpp:148:14: note: synthesized method ‘X<ncbool>::X()’
first required here
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T
-DGIVE_X_EXPLICIT_NONCONST_CTOR
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DUSE_SYNTHESIZED_X_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<ncbool>::X()’:
constexpr-ctor-templ.cpp:100:8: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
constexpr-ctor-templ.cpp:100:8: error: non-constant array initialization
constexpr-ctor-templ.cpp: In function ‘int main(int, char**)’:
constexpr-ctor-templ.cpp:148:14: note: synthesized method ‘X<ncbool>::X()’
first required here
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
--------------------------------------------
+ g++ -c constexpr-ctor-templ.cpp -std=c++0x -DFLAG_T_ARRAY
-DGIVE_X_EXPLICIT_NONCONST_CTOR
--------------------------------------------
Failed 4


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
  2011-02-16 23:12 ` [Bug c++/47774] " dev.lists at jessamine dot co.uk
  2011-02-17  8:38 ` dev.lists at jessamine dot co.uk
@ 2011-02-17 11:30 ` dev.lists at jessamine dot co.uk
  2011-02-17 12:46 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-02-17 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

Adam Butcher <dev.lists at jessamine dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           See Also|                            |http://gcc.gnu.org/bugzilla
                   |                            |/show_bug.cgi?id=46472

--- Comment #3 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-02-17 11:00:01 UTC ---
Added Jason to CC and referenced bug 46472.  The code stated in 46472 works on
current GCC though but the description is similar to this.


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (2 preceding siblings ...)
  2011-02-17 11:30 ` dev.lists at jessamine dot co.uk
@ 2011-02-17 12:46 ` redi at gcc dot gnu.org
  2011-02-21  0:23 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-17 12:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-17 12:14:17 UTC ---
I think this is a dup of bug 46472


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (3 preceding siblings ...)
  2011-02-17 12:46 ` redi at gcc dot gnu.org
@ 2011-02-21  0:23 ` paolo.carlini at oracle dot com
  2011-02-21  3:15 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-02-21  0:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-02-20 23:33:24 UTC ---
Please double check that now that 46472 is fixed this is also fixed.


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (4 preceding siblings ...)
  2011-02-21  0:23 ` paolo.carlini at oracle dot com
@ 2011-02-21  3:15 ` jason at gcc dot gnu.org
  2011-03-01 15:34 ` dev.lists at jessamine dot co.uk
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-02-21  3:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-02-21 02:12:11 UTC ---
Yep, this is fixed too.

*** This bug has been marked as a duplicate of bug 46472 ***


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (5 preceding siblings ...)
  2011-02-21  3:15 ` jason at gcc dot gnu.org
@ 2011-03-01 15:34 ` dev.lists at jessamine dot co.uk
  2011-03-03  2:49 ` jason at gcc dot gnu.org
  2011-03-03  8:40 ` dev.lists at jessamine dot co.uk
  8 siblings, 0 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-03-01 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-03-01 15:34:40 UTC ---
(In reply to comment #6)
> Yep, this is fixed too.
> 
> *** This bug has been marked as a duplicate of bug 46472 ***
>
The attached program demonstrated instances of the bug with various member
types.  It still fails on two cases when using array members.  I don't think
they are errors.  Running

   sh constexpr-ctor-templ.cpp

with 4.6.0 20110301 now yields the following (output compressed for legibility
[snip] = -c constexpr-ctor-templ.cpp -std=c++0x).

--------------------------------------------
+ g++ [snip] -DPLAIN_T       -DUSE_SYNTHESIZED_X_CTOR
+ g++ [snip] -DPLAIN_T       -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
+ g++ [snip] -DPLAIN_T       -DGIVE_X_EXPLICIT_NONCONST_CTOR
+ g++ [snip] -DPLAIN_T_ARRAY -DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ [snip] -DPLAIN_T_ARRAY -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘ncbool::ncbool(bool)’ is not
‘constexpr’
--------------------------------------------
+ g++ [snip] -DPLAIN_T_ARRAY -DGIVE_X_EXPLICIT_NONCONST_CTOR
+ g++ [snip] -DFLAG_T        -DUSE_SYNTHESIZED_X_CTOR
+ g++ [snip] -DFLAG_T        -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
+ g++ [snip] -DFLAG_T        -DGIVE_X_EXPLICIT_NONCONST_CTOR
+ g++ [snip] -DFLAG_T_ARRAY  -DUSE_SYNTHESIZED_X_CTOR
--------------------------------------------
+ g++ [snip] -DFLAG_T_ARRAY  -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR
constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T =
ncbool]’:
constexpr-ctor-templ.cpp:148:14:   instantiated from here
constexpr-ctor-templ.cpp:103:24: error: ‘constexpr flag<BoolType>::flag(bool)
[with BoolType = ncbool]’ is not ‘constexpr’
--------------------------------------------
+ g++ [snip] -DFLAG_T_ARRAY  -DGIVE_X_EXPLICIT_NONCONST_CTOR
--------------------------------------------

Failed 2


The failing invocations occur when an array of a type that cannot be used to
construct compile-time constants is used as a member of X when X is given a
constexpr constructor.  With the new compiler, the result comments become:


--- constexpr-ctor-templ.cpp 2011-03-01 14:57:22.000000000 +0000
+++ constexpr-ctor-templ.cpp 2011-03-01 14:58:55.000000000 +0000
@@ -113,11 +113,11 @@
 #if PLAIN_T
    T mem;            // doesn't fail in any mode
 #elif FLAG_T
-   flag<T> mem;      // fails only with synthesized ctor
+   flag<T> mem;      // doesn't fail in any mode now
 #elif PLAIN_T_ARRAY
    T mem[7];         // fails only with GIVE_X_EXPLICIT_CONSTEXPR_CTOR
 #elif FLAG_T_ARRAY
-   flag<T> mem[7];   // fails unless GIVE_X_EXPLICIT_NONCONST_CTOR
+   flag<T> mem[7];   // fails only with GIVE_X_EXPLICIT_CONSTEXPR_CTOR
 #endif
 };


I.e. The plain array member still fails as it did before and the flag<T> array
member now fails in the same way as the plain array member (which is a change
from how it failed before).


Since the failures are now purely array related, a simplified program with no
macro configuration that reproduces the problem is:

   struct ncbool
   {
      ncbool(bool b = false) : b(b) {}
      bool b;
   };

   template <typename BoolType>
   struct flag
   {
      constexpr flag(BoolType b = false) : b(b) {}
      BoolType b;
   };

   template <typename T>
   struct array
   {
      constexpr array() : mem() {}
      T mem[7];
   };

   int main(int argc, char**)
   {
      // The following are not declared constexpr
      // so shouldn't result in constexpr errors.

      array<ncbool>       array_of_plain_ncbool;
      array<flag<ncbool>> array_of_flag_ncbool;
   }


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (6 preceding siblings ...)
  2011-03-01 15:34 ` dev.lists at jessamine dot co.uk
@ 2011-03-03  2:49 ` jason at gcc dot gnu.org
  2011-03-03  8:40 ` dev.lists at jessamine dot co.uk
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-03  2:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-03 02:49:23 UTC ---
Author: jason
Date: Thu Mar  3 02:49:19 2011
New Revision: 170638

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170638
Log:
    PR c++/47774
    * tree.c (build_vec_init_elt): Split out from...
    (build_vec_init_expr): ...here.
    (diagnose_non_constexpr_vec_init): New fn.
    * semantics.c (potential_constant_expression_1): Use it.
    * cp-tree.h: Declare it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor9.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/47774] [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements
  2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
                   ` (7 preceding siblings ...)
  2011-03-03  2:49 ` jason at gcc dot gnu.org
@ 2011-03-03  8:40 ` dev.lists at jessamine dot co.uk
  8 siblings, 0 replies; 10+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-03-03  8:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-03-03 08:40:28 UTC ---
Great.  That's got rid of the need for the preprocessor hacks to remove
constexpr usage from libstdc++ in c++0x mode.  A full build of our tree from
GCC 4.6 HEAD (including unmodified libstdc++) works fine now.


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

end of thread, other threads:[~2011-03-03  8:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 22:44 [Bug c++/47774] New: [C++0x] constexpr specifier on ctor not ignored when template instantiation causes ctor to not satify constexpr requirements dev.lists at jessamine dot co.uk
2011-02-16 23:12 ` [Bug c++/47774] " dev.lists at jessamine dot co.uk
2011-02-17  8:38 ` dev.lists at jessamine dot co.uk
2011-02-17 11:30 ` dev.lists at jessamine dot co.uk
2011-02-17 12:46 ` redi at gcc dot gnu.org
2011-02-21  0:23 ` paolo.carlini at oracle dot com
2011-02-21  3:15 ` jason at gcc dot gnu.org
2011-03-01 15:34 ` dev.lists at jessamine dot co.uk
2011-03-03  2:49 ` jason at gcc dot gnu.org
2011-03-03  8:40 ` dev.lists at jessamine dot co.uk

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