public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49015] New: [C++0x] Non-defining constexpr function declarations require complete argument/return types
@ 2011-05-16 21:40 daniel.kruegler at googlemail dot com
  2011-05-18 17:38 ` [Bug c++/49015] " jason at gcc dot gnu.org
  2011-05-18 18:00 ` jason at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-05-16 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x] Non-defining constexpr function declarations
                    require complete argument/return types
           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


After successful resolution of bug 48948 gcc 4.7.0 20110514 (experimental) in
C++0x mode now rejects the following code at the lines marked with #L-4 until
#L-13:

//---
class A;
class B;

constexpr B f(A); // #L-4

class B {
  friend constexpr B g(A); // #L-7
};

class A {};

constexpr B f(A) { return B(); } // #L-12
constexpr B g(A) { return B(); } // #L-13
//---

"4|error: invalid type for parameter 1 of constexpr function 'constexpr B
f(A)'|
4|error: invalid return type 'B' of constexpr function 'constexpr B f(A)'|
7|error: invalid type for parameter 1 of constexpr function 'constexpr B g(A)'|
7|error: invalid type for parameter 1 of constexpr function 'constexpr B g(A)'|
|In function 'constexpr B f(A)':|
12|error: redeclaration 'constexpr B f(A)' differs in 'constexpr'|
4|error: from previous declaration 'B f(A)'|
|In function 'constexpr B g(A)':|
13|error: redeclaration 'constexpr B g(A)' differs in 'constexpr'|
7|error: from previous declaration 'B g(A)'|
||=== Build finished: 8 errors, 0 warnings ===|

The parts following line 8 have mainly be added to demonstrate the general
usefulness of the non-defining declarations and the error described by #L-12
and #L-13 is possibly overlaid by bug 48945 as well, so the main aspect of this
issue are the #L-4 and #L-7 rejections if interaction with bug 48945 is the
cause of #L-12 and #L-13.

I don't think that the literal-type requirements as of 3.9 p. 10 impose the
requirements of complete types for the non-defining declarations of these
constexpr functions, IMO the requirement for the complete type is only required
for the final definition of f and g, which also seems to be intended as
described by the example of 7.1.5 p. 1. In principle these examples are also
not much different from constexpr function templates, which must delay the
evaluation until the concrete instantiation and usage (The last aspect becomes
clear by the 7.1.5 p. 1 example and demonstrates that this is a general
character of constexpr functions irrespective of templates).


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

* [Bug c++/49015] [C++0x] Non-defining constexpr function declarations require complete argument/return types
  2011-05-16 21:40 [Bug c++/49015] New: [C++0x] Non-defining constexpr function declarations require complete argument/return types daniel.kruegler at googlemail dot com
@ 2011-05-18 17:38 ` jason at gcc dot gnu.org
  2011-05-18 18:00 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-18 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-18 17:19:19 UTC ---
Author: jason
Date: Wed May 18 17:19:15 2011
New Revision: 173869

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173869
Log:
    PR c++/48948
    PR c++/49015
    * class.c (finalize_literal_type_property): Do check
    for constexpr member functions of non-literal class.
    (finish_struct): Don't call check_deferred_constexpr_decls.
    * cp-tree.h: Don't declare it.
    (DECL_DEFERRED_CONSTEXPR_CHECK): Remove.
    * decl.c (grok_special_member_properties): Don't check it
    (grokfnedcl): Don't call validate_constexpr_fundecl.
    (start_preparsed_function): Do call it.
    * pt.c (tsubst_decl): Don't call it.
    (instantiate_class_template_1): Don't call
    check_deferred_constexpr_decls.
    * semantics.c (literal_type_p): Check for any incompleteness.
    (ensure_literal_type_for_constexpr_object): Likewise.
    (is_valid_constexpr_fn): Revert deferral changes.
    (validate_constexpr_fundecl): Likewise.
    (register_constexpr_fundef): Likewise.
    (check_deferred_constexpr_decls): Remove.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-memfn1.C


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

* [Bug c++/49015] [C++0x] Non-defining constexpr function declarations require complete argument/return types
  2011-05-16 21:40 [Bug c++/49015] New: [C++0x] Non-defining constexpr function declarations require complete argument/return types daniel.kruegler at googlemail dot com
  2011-05-18 17:38 ` [Bug c++/49015] " jason at gcc dot gnu.org
@ 2011-05-18 18:00 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-18 18:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-18 17:47:58 UTC ---
Fixed.


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-16 21:40 [Bug c++/49015] New: [C++0x] Non-defining constexpr function declarations require complete argument/return types daniel.kruegler at googlemail dot com
2011-05-18 17:38 ` [Bug c++/49015] " jason at gcc dot gnu.org
2011-05-18 18:00 ` jason 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).