Title
[tiny] Returning a void expression from a constructor or destructor
Status
nad
Section
[stmt.return]
Submitter
Richard Smith

Created on 2013-07-02.00:00:00 last changed 135 months ago

Messages

Date: 2013-10-11.23:34:25

A thread on std-discussion[1] has highlighted that

  return E;

where E has type void is valid in a function with a return type of 'void' but not valid in a constructor or destructor. There is implementation variance here, and we have examples of code which very reasonably wants to use "return E;" in a constructor, from within the expansion of a macro, and fails on some compilers due to this rule. The inconsistency between "return;" and "return void();" seems extremely jarring here, and I'd like to propose that we treat this as a defect.

(I'm not suggesting that we treat constructors and destructors as having a return type of 'void', as was suggested on the thread on std-discussion, but I'm not opposed to it.)

[1] https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/ehqGBMsswjk

Discussed in Chicago 2013 (as the NB comment FI 6), no consensus to make a change, NB comment rejected, the issue is NAD. Vandevoorde said this rubs him the wrong way, because this suggests that a constructor returns nothing even though that's not the case.

History
Date User Action Args
2013-10-11 23:34:25adminsetstatus: open -> nad
2013-07-02 00:00:00admincreate