From -2515855146256963592
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,857007135a18bc05
X-Google-Attributes: gidf78e5,public
From: sbnaran@uiuc.edu (Siemel B. Naran)
Subject: Re: static_cast to void
Date: 1999/09/12
Message-ID: <slrn7tmc4u.p2c.sbnaran@localhost.localdomain>#1/1
X-Deja-AN: 524106139
X-NNTP-Posting-Host: rochester-35.slip.uiuc.edu
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <M-MORITA.99Sep9141115@pdss7.trc.rwcp.or.jp> <slrn7tgtbq.8tp.sbnaran@localhost.localdomain> <WwJQQZA6Jj23EwF3@robinton.demon.co.uk>
X-UID: 0000000001
X-Status: $$$T
Organization: University of Illinois at Urbana-Champaign
User-Agent: slrn/0.9.5.7 (UNIX)
Reply-To: sbnaran@uiuc.edu
Newsgroups: comp.std.c++
Originator: clamage@taumet


On 11 Sep 1999 16:38:19 GMT, Francis Glassborow
>In article <slrn7tgtbq.8tp.sbnaran@localhost.localdomain>, Siemel B.

>>Sometimes you write expressions that return a value, but you don't use
>>this returned value.  Then the compiler may give you a warning about
>>the unused return value.  To shut off these warnings, put a "(void)"
>>at the beginning of the line.  For example,
>
>Do such compilers exist in the real world?  Because if so they must be
>exceptionally noisy.  Strictly speaking they should warn me for:
>
>cout << 1;

No.  Note that the definition of std::ostream::operator<<(int) is
outline (ie, not inline), or it calls functions that are outline.
So the compiler must assume that the function has some side effects.
So the compiler is not justified in giving warnings.

The example I gave was
   static_cast<SomeClass *>((Template*)0);
My compilers do give me warnings for failing to use the return type.

At the end of my post, I said that there might be better examples.
But I can't think of any.

-- 
--------------
siemel b naran
--------------


[ 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              ]




