public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound
@ 2011-04-09 17:09 daniel.kruegler at googlemail dot com
  2011-04-14 15:00 ` [Bug c++/48531] " jason at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-09 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x][SFINAE] Hard errors with arrays of unknown
                    bound
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@redhat.com


The following program should be well-formed, but is not:

template<class T,
  class = decltype(T())
>
char f(int);

template<class>
char (&f(...))[2];

static_assert(sizeof(f<int[]>(0)) != 1, "Error"); 

"cannot value-initialize array of unknown bound ‘int []’"


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
@ 2011-04-14 15:00 ` jason at gcc dot gnu.org
  2011-04-14 15:11 ` jason at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-14 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-14 15:00:18 UTC ---
Author: jason
Date: Thu Apr 14 15:00:15 2011
New Revision: 172434

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172434
Log:
    PR c++/48531
    * init.c (build_value_init_noctor): Check complain consistently.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
  2011-04-14 15:00 ` [Bug c++/48531] " jason at gcc dot gnu.org
@ 2011-04-14 15:11 ` jason at gcc dot gnu.org
  2011-04-14 17:56 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-14 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-14 15:11:28 UTC ---
Fixed.


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
  2011-04-14 15:00 ` [Bug c++/48531] " jason at gcc dot gnu.org
  2011-04-14 15:11 ` jason at gcc dot gnu.org
@ 2011-04-14 17:56 ` paolo.carlini at oracle dot com
  2011-04-14 23:00 ` daniel.kruegler at googlemail dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-14 17:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-14 17:55:43 UTC ---
Thanks Jason. Now Daniel we have to figure out which other bug (ie, possibly
prepare a reduced testcase for Jason) prevents us from getting rid completely
of the special casing for default_constructible in <type_traits>: I quickly
tried and  got the ICE

  in build_value_init_noctor, at cp/init.c:455


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-04-14 17:56 ` paolo.carlini at oracle dot com
@ 2011-04-14 23:00 ` daniel.kruegler at googlemail dot com
  2011-04-14 23:06 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-14 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-14 23:00:05 UTC ---
(In reply to comment #3)

Here is a minimalistic example that provokes the same error. The essence is,
that the construction expression is evaluated combined with another
construction or destruction expression in a single (constant) expression. The
other expressions seems not relevant, it can even be the same expression, like
here:

//-------------------
template<class T,
  class = decltype(T())
>
char f(int);

template<class>
double f(...);

struct B2 {
  B2(...);
};

constexpr bool b = sizeof(f<B2[1]>(0)) == 1 && sizeof(f<B2[1]>(0)) == 1;
//-------------------

"main.cpp:13:37: internal compiler error: in build_value_init_noctor, at
cp/init.c:455"

Another example case is, when we combine a destructor expression with a
constructor expression like this (Note that B1 is a slightly differently here):

template<class T,
  class = decltype(T())
>
char f(int);

template<class>
double f(...);

template<class T>
T&& create();

template<class T,
  class = decltype(create<T&>().~T())
>
char g(int);

template<class>
double g(...);

template<class... T>
struct B1 {
  B1(T...);
};

constexpr bool b = sizeof(g<B1<>[1]>(0)) == 1 && sizeof(f<B1<>[1]>(0)) == 1;


This gives exactly the same error:

"main.cpp:31:69: internal compiler error: in build_value_init_noctor, at
cp/init.c:455"

In addition to the ICE the new code gives incorrect results for an array with
known bounds of type with deleted d'tor. Given the same f as defined above
(testing for default construction):

struct D { ~D() = delete; };

static_assert(sizeof(f<D[1]>(0)) != 1, "Error");

the static assertion fires.


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2011-04-14 23:00 ` daniel.kruegler at googlemail dot com
@ 2011-04-14 23:06 ` paolo.carlini at oracle dot com
  2011-04-18  0:51 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-14 23:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2011.04.14 23:06:10
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com
         Resolution|FIXED                       |
     Ever Confirmed|0                           |1

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-14 23:06:10 UTC ---
Thanks a lot for the hard work Daniel!

I hope Jason doesn't mind if I just re-open this PR (instead of filing a new
one), thus asking again for his help...


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2011-04-14 23:06 ` paolo.carlini at oracle dot com
@ 2011-04-18  0:51 ` jason at gcc dot gnu.org
  2011-04-18  4:23 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-18 00:50:37 UTC ---
Author: jason
Date: Mon Apr 18 00:50:31 2011
New Revision: 172632

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172632
Log:
    PR c++/48531
    * typeck2.c (build_functional_cast): Disallow array type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae16.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2011-04-18  0:51 ` jason at gcc dot gnu.org
@ 2011-04-18  4:23 ` jason at gcc dot gnu.org
  2011-04-18 11:05 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18  4:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-18 04:22:32 UTC ---
Testcases in comment 4 fixed as well (apart from the separate deleted dtor
issue).


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (6 preceding siblings ...)
  2011-04-18  4:23 ` jason at gcc dot gnu.org
@ 2011-04-18 11:05 ` paolo.carlini at oracle dot com
  2011-04-18 11:13 ` daniel.kruegler at googlemail dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-18 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-18 11:02:59 UTC ---
Thanks. But I'm confused by what is replacing the hard-error. Isn't this
supposed to be well-formed?

template<class T,
  class = decltype(T())
>
char f(int);

template<class>
double f(...);

static_assert(sizeof(f<int[1]>(0)) == 1, "Error");


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (7 preceding siblings ...)
  2011-04-18 11:05 ` paolo.carlini at oracle dot com
@ 2011-04-18 11:13 ` daniel.kruegler at googlemail dot com
  2011-04-18 11:36 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-18 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-18 11:12:14 UTC ---
(In reply to comment #8)
> Thanks. But I'm confused by what is replacing the hard-error. Isn't this
> supposed to be well-formed?
> 
> template<class T,
>   class = decltype(T())
> >
> char f(int);
> 
> template<class>
> double f(...);
> 
> static_assert(sizeof(f<int[1]>(0)) == 1, "Error");

Yes, this is supposed to be well-formed. I have not checked the most recent gcc
state yet (but will do this evening), is this code not accepted?


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (8 preceding siblings ...)
  2011-04-18 11:13 ` daniel.kruegler at googlemail dot com
@ 2011-04-18 11:36 ` paolo.carlini at oracle dot com
  2011-04-18 11:48 ` daniel.kruegler at googlemail dot com
  2011-04-18 12:17 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-18 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-18 11:33:34 UTC ---
It is not accepted.

I tried again to remove the special code for is_default_constructible in
<type_traits> and a number of static_asserts, all having to do with arrays
fired...


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (9 preceding siblings ...)
  2011-04-18 11:36 ` paolo.carlini at oracle dot com
@ 2011-04-18 11:48 ` daniel.kruegler at googlemail dot com
  2011-04-18 12:17 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-18 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-18 11:47:15 UTC ---
(In reply to comment #10)
> It is not accepted.
> 
> I tried again to remove the special code for is_default_constructible in
> <type_traits> and a number of static_asserts, all having to do with arrays
> fired...

I was wrong, I just notice that the FDIS wording says in regard to the
expression T() in [expr.type.conv] p. 2:

"The expression T(), where T is a simple-type-specifier or typename-specifier
for a non-array complete object type or the (possibly cv-qualified) void type,
creates a prvalue of the specified type,which is value-initialized"

So, it seems that the current protection code in the library is necessary as of
this wording, but I'm no longer sure that the core wording reflects the
intention, because array rvalues are clearly supported.


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

* [Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
  2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
                   ` (10 preceding siblings ...)
  2011-04-18 11:48 ` daniel.kruegler at googlemail dot com
@ 2011-04-18 12:17 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-18 12:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-18 12:13:41 UTC ---
Interesting, thanks. Then I guess we should stop bothering Jason.

Closing PR again.


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

end of thread, other threads:[~2011-04-18 12:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-09 17:09 [Bug c++/48531] New: [C++0x][SFINAE] Hard errors with arrays of unknown bound daniel.kruegler at googlemail dot com
2011-04-14 15:00 ` [Bug c++/48531] " jason at gcc dot gnu.org
2011-04-14 15:11 ` jason at gcc dot gnu.org
2011-04-14 17:56 ` paolo.carlini at oracle dot com
2011-04-14 23:00 ` daniel.kruegler at googlemail dot com
2011-04-14 23:06 ` paolo.carlini at oracle dot com
2011-04-18  0:51 ` jason at gcc dot gnu.org
2011-04-18  4:23 ` jason at gcc dot gnu.org
2011-04-18 11:05 ` paolo.carlini at oracle dot com
2011-04-18 11:13 ` daniel.kruegler at googlemail dot com
2011-04-18 11:36 ` paolo.carlini at oracle dot com
2011-04-18 11:48 ` daniel.kruegler at googlemail dot com
2011-04-18 12:17 ` 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).