Topic: throw-expression


Author: wmm@fastdial.net
Date: 2000/03/31
Raw View
In a previous article,  <fjh@cs.mu.OZ.AU> writes:
>>What is "return" type of throw-expression? It is not defined in 15.1.
>
>It is `void'.
>
>But I can't find any normative wording in the standard which specifically
says
>that.  That looks to me like a defect in the standard; you might want to
>consider submitting a defect report.

15p1: "A throw-expression is of type void."



     -----  Posted via NewsOne.Net: Free Usenet News via the Web  -----
     -----  http://newsone.net/ --  Discussions on every subject. -----
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: aalimari <aalimari@best.ms.philips.com>
Date: 2000/03/30
Raw View
I am wandering why throw-expression is an assignment-expression [A.4],
why is not it a jump-statement [A.5].
What possible use of it's expressionness could be?
What is "return" type of throw-expression? It is not defined in 15.1.
Two different compilers thhink it is void, which seems reasonable.



---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: fjh@cs.mu.OZ.AU (Fergus Henderson)
Date: 2000/03/31
Raw View
aalimari <aalimari@best.ms.philips.com> writes:

>I am wandering why throw-expression is an assignment-expression [A.4],
>why is not it a jump-statement [A.5].
>What possible use of it's expressionness could be?

See the recent discussion in comp.compilers, where someone
was suggesting that even `return' in C should be a void-valued
expression rather than a statement.

Or, for a more C++-specific example, consider the use
of throw-expressions inside conditional-expressions
in mem-initializers:

 class Derived : public Base {
 public:
  Derived(Foo *p)
   : Base(p ? *p : throw "null Foo *")
  {}

>What is "return" type of throw-expression? It is not defined in 15.1.

It is `void'.

But I can't find any normative wording in the standard which specifically says
that.  That looks to me like a defect in the standard; you might want to
consider submitting a defect report.

The closest I could find was in 5.16 paragraph 2, which discusses
conditional-expressions:

 |    -2- If either the second or the third operand has type (possibly
 |    cv-qualified) void, then the lvalue-to-rvalue (conv.lval),
 |    array-to-pointer (conv.array), and function-to-pointer (conv.func)
 |    standard conversions are performed on the second and third operands,
 |    and one of the following shall hold:
 |      * The second or the third operand (but not both) is a
 |        throw-expression (except.throw); the result is of the type of the
 |        other and is an rvalue.
 |
 |      * Both the second and the third operands have type void; the result
 |        is of type void and is an rvalue. [Note: this includes the case
 |        where both operands are throw-expressions. ]

Here the wording clearly implies that throw-expressions _can_ have
type `void', but it's not clear from the normative wording here that
they _must_ have type `void'.

--
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]