public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile
@ 2014-03-19 18:49 dblaikie at gmail dot com
  2014-03-19 19:04 ` [Bug libstdc++/60594] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dblaikie at gmail dot com @ 2014-03-19 18:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60594
           Summary: std::function of a type with a declared (but not
                    defined) return type fails to compile
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dblaikie at gmail dot com
                CC: chandlerc at gmail dot com

#include <functional>
#include <type_traits>
struct bar;
#if BUG1
struct foo { std::function<bar ()> f; };
#elif BUG2
int i = std::is_copy_constructible<std::function<bar()>>::value;
#else
std::function<bar ()> b;
#endif
struct bar { };
int main() {
  std::function<bar ()> g([] { return bar(); });
}

Clang rejects both BUG1 and BUG2.
GCC ToT (20140219) rejects BUG2.

(I believe the Clang rejection of BUG1 is erroneous and will file a bug for
that)

libc++ with Clang compiles successfully in all 3 variants.

It looks like, somehow, instantiating the declaration of the std::function copy
constructor relies on the completeness of 'bar'.


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
@ 2014-03-19 19:04 ` redi at gcc dot gnu.org
  2014-03-19 19:48 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-19 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Are you sure this is valid? Instantiating std::function (like most std::lib
templates) with an incomplete type is undefined behaviour. Is the function type
bar() complete if bar is not complete?


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
  2014-03-19 19:04 ` [Bug libstdc++/60594] " redi at gcc dot gnu.org
@ 2014-03-19 19:48 ` redi at gcc dot gnu.org
  2014-03-19 20:52 ` chandlerc at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-19 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> It looks like, somehow, instantiating the declaration of the std::function
> copy constructor relies on the completeness of 'bar'.

I suspect it's not the copy constructor, but that checking for copy
constructibility performs overload resolution, which instantiates the SFINAE
constraint on the function(F&&) constructor, which probably relies on
completeness of the result_type


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
  2014-03-19 19:04 ` [Bug libstdc++/60594] " redi at gcc dot gnu.org
  2014-03-19 19:48 ` redi at gcc dot gnu.org
@ 2014-03-19 20:52 ` chandlerc at gmail dot com
  2014-03-19 21:22 ` daniel.kruegler at googlemail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: chandlerc at gmail dot com @ 2014-03-19 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Chandler Carruth <chandlerc at gmail dot com> ---
Personally, I've no idea what the standard says.

However, it seems extremely useful to be able to freely use std::function with
return types (and argument types) within the definition those types which is
how this actually started. It also seems reasonable to need to observe whether
the std::function will be copyable (it will) prior to completing it.

Without this, somewhat basic uses if std::function as a member with a
type-erased bit of logic pertaining to the enclosing class with value semantic
interfaces don't work.


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (2 preceding siblings ...)
  2014-03-19 20:52 ` chandlerc at gmail dot com
@ 2014-03-19 21:22 ` daniel.kruegler at googlemail dot com
  2014-04-08  4:16 ` kariya_mitsuru at hotmail dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-03-19 21:22 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 4387 bytes --]

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> Are you sure this is valid?

I tend to say it is valid, see below for a further comment on this.

> Instantiating std::function (like most std::lib
> templates) with an incomplete type is undefined behaviour. Is the function
> type bar() complete if bar is not complete?

This is definitively true (i.e. bar() is a complete type), because function
types are not affected by the definition of complete types, 3.9 p. says:

"Incompletely defined object types and the void types are incomplete types
(3.9.1)."

I would say that the definition of "INVOKE(f, t1, t2, ..., tN, R)" is not
well-defined for incomplete R (except when R==void) due to the
"implicitly-convertible" constraint mentioned in 20.9.2 p2, but 20.9.11 doesn't
seem to impose this constraint to hold when instantiating a std::function<>. On
the other hand the current std::function wording clearly is underspecified:
There are several members that would require R to be a complete type. I don't
think that the default constructor is one of these, though. Among the members
where this is needed is IMO

template<class F> function(F f);

because the compile-time constraint

"unless f is Callable (20.9.11.2) for argument types ArgTypes... and return
type R."

can only be deduced, if R is complete (modulo void again).
>From gcc-bugs-return-446941-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Mar 19 21:30:40 2014
Return-Path: <gcc-bugs-return-446941-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9421 invoked by alias); 19 Mar 2014 21:30:40 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 9398 invoked by uid 48); 19 Mar 2014 21:30:37 -0000
From: "patnel97269-gfortran at yahoo dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60596] New: Inquire size for stream zero
Date: Wed, 19 Mar 2014 21:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: patnel97269-gfortran at yahoo dot fr
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-60596-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg01810.txt.bz2
Content-length: 764

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`596

            Bug ID: 60596
           Summary: Inquire size for stream zero
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patnel97269-gfortran at yahoo dot fr

Created attachment 32398
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2398&actioníit
program

Hi all,

When calling inquire for a stream size, the size is reported to be zero.

In the intel fortran compiler the sizer is correctly reported.

I attached a small program, and the necessary input file.


Use that as < input :
>ONE Homo sapiens alu


Thanks.


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (3 preceding siblings ...)
  2014-03-19 21:22 ` daniel.kruegler at googlemail dot com
@ 2014-04-08  4:16 ` kariya_mitsuru at hotmail dot com
  2014-04-08 10:07 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2014-04-08  4:16 UTC (permalink / raw)
  To: gcc-bugs

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

Mitsuru Kariya <kariya_mitsuru at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kariya_mitsuru at hotmail dot com

--- Comment #5 from Mitsuru Kariya <kariya_mitsuru at hotmail dot com> ---
FYI, the BUG2 above is compiled successfully by gcc 4.7.3.

cf. http://melpon.org/wandbox/permlink/UZdP4fovs2ATM2iZ


Additionally, the sample code below cannot be compiled by gcc HEAD.

#include <functional>

struct S {
    std::function<S()> f;
};

int main()
{
    S l{ []{ return S{nullptr}; } };
}

cf. http://melpon.org/wandbox/permlink/HAZ7i5JE94KSQhM7


It is also compiled successfully by gcc 4.7.3.
And I think that struct S is not incomplete type (at least, at the point where
it is used).


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

* [Bug libstdc++/60594] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (4 preceding siblings ...)
  2014-04-08  4:16 ` kariya_mitsuru at hotmail dot com
@ 2014-04-08 10:07 ` redi at gcc dot gnu.org
  2014-04-15 15:26 ` [Bug libstdc++/60594] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-08 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Mitsuru Kariya from comment #5)
> FYI, the BUG2 above is compiled successfully by gcc 4.7.3.

Yes, but std::function in 4.7.3 fails other, more important tests.


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

* [Bug libstdc++/60594] [4.8/4.9/4.10 Regression] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (5 preceding siblings ...)
  2014-04-08 10:07 ` redi at gcc dot gnu.org
@ 2014-04-15 15:26 ` redi at gcc dot gnu.org
  2014-04-15 15:27 ` [Bug libstdc++/60594] [4.8/4.9 " redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Apr 15 15:25:52 2014
New Revision: 209422

URL: http://gcc.gnu.org/viewcvs?rev=209422&root=gcc&view=rev
Log:
    PR libstdc++/60594
    * include/std/functional (function::_Callable): Exclude own type
    from the callable checks.
    * testsuite/20_util/function/60594.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/20_util/function/60594.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/functional


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

* [Bug libstdc++/60594] [4.8/4.9 Regression] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (6 preceding siblings ...)
  2014-04-15 15:26 ` [Bug libstdc++/60594] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
@ 2014-04-15 15:27 ` redi at gcc dot gnu.org
  2014-05-06 11:45 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.10.0
            Summary|[4.8/4.9/4.10 Regression]   |[4.8/4.9 Regression]
                   |std::function of a type     |std::function of a type
                   |with a declared (but not    |with a declared (but not
                   |defined) return type fails  |defined) return type fails
                   |to compile                  |to compile

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far


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

* [Bug libstdc++/60594] [4.8/4.9 Regression] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (7 preceding siblings ...)
  2014-04-15 15:27 ` [Bug libstdc++/60594] [4.8/4.9 " redi at gcc dot gnu.org
@ 2014-05-06 11:45 ` redi at gcc dot gnu.org
  2014-05-06 13:28 ` redi at gcc dot gnu.org
  2014-05-06 13:29 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-06 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue May  6 11:45:14 2014
New Revision: 210103

URL: http://gcc.gnu.org/viewcvs?rev=210103&root=gcc&view=rev
Log:
Backport libstdc++/60594 fix from mainline.

    PR libstdc++/60594
    * include/std/functional (function::_Callable): Exclude own type
    from the callable checks.
    * testsuite/20_util/function/60594.cc: New.

Added:
    branches/gcc-4_9-branch/libstdc++-v3/testsuite/20_util/function/60594.cc
Modified:
    branches/gcc-4_9-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_9-branch/libstdc++-v3/include/std/functional


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

* [Bug libstdc++/60594] [4.8/4.9 Regression] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (8 preceding siblings ...)
  2014-05-06 11:45 ` redi at gcc dot gnu.org
@ 2014-05-06 13:28 ` redi at gcc dot gnu.org
  2014-05-06 13:29 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-06 13:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue May  6 13:27:46 2014
New Revision: 210105

URL: http://gcc.gnu.org/viewcvs?rev=210105&root=gcc&view=rev
Log:
Backport libstdc++/60594 fix from mainline.

    PR libstdc++/60594
    * include/std/functional (function::_Callable): Exclude own type
    from the callable checks.
    * testsuite/20_util/function/60594.cc: New.

Added:
    branches/gcc-4_8-branch/libstdc++-v3/testsuite/20_util/function/60594.cc
Modified:
    branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_8-branch/libstdc++-v3/include/std/functional


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

* [Bug libstdc++/60594] [4.8/4.9 Regression] std::function of a type with a declared (but not defined) return type fails to compile
  2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
                   ` (9 preceding siblings ...)
  2014-05-06 13:28 ` redi at gcc dot gnu.org
@ 2014-05-06 13:29 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-06 13:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
      Known to fail|                            |4.8.2, 4.9.0

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 4.8.3 and 4.9.1


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

end of thread, other threads:[~2014-05-06 13:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 18:49 [Bug libstdc++/60594] New: std::function of a type with a declared (but not defined) return type fails to compile dblaikie at gmail dot com
2014-03-19 19:04 ` [Bug libstdc++/60594] " redi at gcc dot gnu.org
2014-03-19 19:48 ` redi at gcc dot gnu.org
2014-03-19 20:52 ` chandlerc at gmail dot com
2014-03-19 21:22 ` daniel.kruegler at googlemail dot com
2014-04-08  4:16 ` kariya_mitsuru at hotmail dot com
2014-04-08 10:07 ` redi at gcc dot gnu.org
2014-04-15 15:26 ` [Bug libstdc++/60594] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-04-15 15:27 ` [Bug libstdc++/60594] [4.8/4.9 " redi at gcc dot gnu.org
2014-05-06 11:45 ` redi at gcc dot gnu.org
2014-05-06 13:28 ` redi at gcc dot gnu.org
2014-05-06 13:29 ` 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).