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

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