public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57724] New: wrong error: returning a value from a constructor
@ 2013-06-26 11:15 joerg.richter@pdv-fs.de
  2013-06-26 11:31 ` [Bug c++/57724] " fanael4 at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: joerg.richter@pdv-fs.de @ 2013-06-26 11:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57724
           Summary: wrong error: returning a value from a constructor
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joerg.richter@pdv-fs.de

cat > t.cc <<EOF
void func();
struct A
{
    A()
    {
      return func();
    }
};
EOF
gcc t.cc


Produces:

t.cc: In constructor 'A::A()':
t.cc:6:19: error: returning a value from a constructor

I think this should work. (At least clang accepts it.)


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

* [Bug c++/57724] wrong error: returning a value from a constructor
  2013-06-26 11:15 [Bug c++/57724] New: wrong error: returning a value from a constructor joerg.richter@pdv-fs.de
@ 2013-06-26 11:31 ` fanael4 at gmail dot com
  2013-06-26 11:46 ` joerg.richter@pdv-fs.de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: fanael4 at gmail dot com @ 2013-06-26 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

Fanael <fanael4 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fanael4 at gmail dot com

--- Comment #1 from Fanael <fanael4 at gmail dot com> ---
12.1/12 (C++03) and 12.1/9 (C++11) state:

> A return statement in the body of a constructor shall not specify a return value.

It's a bug in Clang, not in GCC.


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

* [Bug c++/57724] wrong error: returning a value from a constructor
  2013-06-26 11:15 [Bug c++/57724] New: wrong error: returning a value from a constructor joerg.richter@pdv-fs.de
  2013-06-26 11:31 ` [Bug c++/57724] " fanael4 at gmail dot com
@ 2013-06-26 11:46 ` joerg.richter@pdv-fs.de
  2013-06-26 23:30 ` paolo.carlini at oracle dot com
  2013-06-27  7:14 ` joerg.richter@pdv-fs.de
  3 siblings, 0 replies; 5+ messages in thread
From: joerg.richter@pdv-fs.de @ 2013-06-26 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jörg Richter <joerg.richter@pdv-fs.de> ---
You mean the special case for 'void' does not apply in this case?
What a pity.
>From gcc-bugs-return-425191-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jun 26 11:49:10 2013
Return-Path: <gcc-bugs-return-425191-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23395 invoked by alias); 26 Jun 2013 11:49:10 -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 23359 invoked by uid 48); 26 Jun 2013 11:49:07 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57724] wrong error: returning a value from a constructor
Date: Wed, 26 Jun 2013 11:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
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:
Message-ID: <bug-57724-4-H90EaaWZJd@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57724-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57724-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: 2013-06/txt/msg01570.txt.bz2
Content-length: 566

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW724

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'm inclined to say this is a Clang bug too.

[stmt.return]/3 "A return statement with an expression of type void can be used
only in functions with a return type of cv void;" and constructors do not have
any return type, not even void.

[class.ctor]/8 "A return statement in the body of a constructor shall not
specify a return value."  That doesn't really help, because a return statement
with an expression of type void does not return a value.


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

* [Bug c++/57724] wrong error: returning a value from a constructor
  2013-06-26 11:15 [Bug c++/57724] New: wrong error: returning a value from a constructor joerg.richter@pdv-fs.de
  2013-06-26 11:31 ` [Bug c++/57724] " fanael4 at gmail dot com
  2013-06-26 11:46 ` joerg.richter@pdv-fs.de
@ 2013-06-26 23:30 ` paolo.carlini at oracle dot com
  2013-06-27  7:14 ` joerg.richter@pdv-fs.de
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-26 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Basing on the analysis provided by Jon + the most recent ICC also rejects the
snippet, I think we can safely close the bug.


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

* [Bug c++/57724] wrong error: returning a value from a constructor
  2013-06-26 11:15 [Bug c++/57724] New: wrong error: returning a value from a constructor joerg.richter@pdv-fs.de
                   ` (2 preceding siblings ...)
  2013-06-26 23:30 ` paolo.carlini at oracle dot com
@ 2013-06-27  7:14 ` joerg.richter@pdv-fs.de
  3 siblings, 0 replies; 5+ messages in thread
From: joerg.richter@pdv-fs.de @ 2013-06-27  7:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jörg Richter <joerg.richter@pdv-fs.de> ---
BTW: There is currently a discussion [1] on this topic on the 
"ISO C++ Standard - Discussion" list.

[1]
https://groups.google.com/a/isocpp.org/d/msg/std-discussion/ehqGBMsswjk/nbsubYASnPgJ
>From gcc-bugs-return-425266-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 27 08:52:10 2013
Return-Path: <gcc-bugs-return-425266-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6128 invoked by alias); 27 Jun 2013 08:52:10 -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 6082 invoked by uid 48); 27 Jun 2013 08:52:04 -0000
From: "petschy at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/57723] Missed optimization: recursion around empty function
Date: Thu, 27 Jun 2013 08:52:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: petschy at gmail dot com
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:
Message-ID: <bug-57723-4-j8KTRt3L5T@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57723-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57723-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: 2013-06/txt/msg01645.txt.bz2
Content-length: 644

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW723

--- Comment #7 from petschy at gmail dot com ---
Is it a plausible assumption that if a function is not marked as 'noreturn' and
the loop doesn't change the program's state then the loop could be optimized
away?

Cases:
- the loop terminates, but the state is not changed, NOP
- the loop does not terminate (in this case a cycle of the Node's), but the
function should return (no noreturn attr), so this is probably a bug in the prg

I can't think of any cases right now for the second point where that would be
the desired behaviour of the program, instead of a bug. Please comment on this.


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

end of thread, other threads:[~2013-06-27  7:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 11:15 [Bug c++/57724] New: wrong error: returning a value from a constructor joerg.richter@pdv-fs.de
2013-06-26 11:31 ` [Bug c++/57724] " fanael4 at gmail dot com
2013-06-26 11:46 ` joerg.richter@pdv-fs.de
2013-06-26 23:30 ` paolo.carlini at oracle dot com
2013-06-27  7:14 ` joerg.richter@pdv-fs.de

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