From 8313011565058386141
X-Google-Thread: f78e5,1e6093a60facd084
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl.net!news-lond.gip.net!news-raspail.gip.net!news.gsl.net!gip.net!grolier!skynet.be!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: tommi.hoynalanmaa@iki.fi (=?ISO-8859-1?Q?Tommi_H=F6yn=E4l=E4nmaa?=)
Newsgroups: comp.std.c++
Subject: Re: [Proposal] noreturn_t
Date: Sun, 29 Oct 2006 01:06:49 GMT
Organization: Saunalahti Customer
Lines: 54
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <QuO0h.40384$V%7.8695@reader1.news.jippii.net>
References: <1161490402.699940.293180@b28g2000cwb.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: news.demon.co.uk 1162084024 21239 158.152.254.254 (29 Oct 2006 01:07:04 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 29 Oct 2006 01:07:04 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Thunderbird 1.5.0.7 (X11/20060922)
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.csse.unimelb.edu.au id k9T16xM6014922
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.6+Sun/8.13.6/Submit) id k9T16nQl014858;
	Sun, 29 Oct 2006 12:06:49 +1100 (EST)
X-NNTP-Posting-Date: Sat, 28 Oct 2006 22:49:04 EEST
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news2.google.com comp.std.c++:4235

Andrei Polushin kirjoitti:
> I propose to add a special type, std::noreturn_t, to indicate that
> function does never return.
>=20
> Actually, some compilers have the similar feature, known as either
> __declspec(noreturn) or __attribute__ ((noreturn)), but it is used
> primarily for optimization purposes and does not affect language.

This is a question about the execution flow and not about the result=20
type of a function. There would be no values whose type is noreturn_t.
So "noreturn" should be an attribute of a function like the throw=20
specifications.

"noreturn" and other attributes should be part of the type of the=20
function (i.e. function pointer type), not the type of the result value.

BTW, there should also be attribute "pure" to indicate that a function=20
has no side effects. A pure function would not be allowed to call any=20
non-pure functions or to change global variables. GCC implements "pure"=20
and "const" attributes for pure functions.

C++ should also have a standardized syntax for the (standard) function=20
attributes. Perhaps something like

   void myfunc(int a, char b) attributes(noreturn)

A function with the pure attribute would be compatible with the=20
corresponding function type with or without the pure attribute. A=20
function without the pure attribute would not be compatible with
the corresponding function type with the pure attribute.

There could be another attribute "mustreturn" to indicate that a=20
function has to return. "mustreturn" and "noreturn" would be mutually=20
exclusive.
Then
- A function with neither of the return attributes would be compatible=20
with the corresponding function type with or without "noreturn" or=20
"mustreturn" attributes.
- A function with "noreturn" attribute would not be compatible with the=20
corresponding function type with the "mustreturn" attribute.
- A function with "mustreturn" attribute would not be compatible with=20
the corresponding function type with the "noreturn" attribute.

--=20
Tommi H=F6yn=E4l=E4nmaa
s=E4hk=F6posti / e-mail: tommi.hoynalanmaa@iki.fi
kotisivu / homepage: http://www.iki.fi/tohoyn/

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



