473,809 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C style casts

Where is it in the standard that C style casts are labeled depricated?
I read that on a lot of websites but I can't find it in the standard.
I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
Sons. I'm in the middle of a standard argument on this issue and
safety isn't convincing my opponents - deprication might.

Jan 31 '06
24 1986
dakka" <"news at electro dot mine dot nu wrote:
Victor Bazarov wrote:
Dakka wrote:
Victor Bazarov wrote:

ro**********@gm ail.com wrote:

> Where is it in the standard that C style casts are labeled
> depricated?
Deprecated? Nowhere. 5.4 describes the explicit type conversion
and what
it means.

> I read that on a lot of websites but I can't find it in the
> standard.
Because it's not there. What web site claims that it's
deprecated? Can you post a link?

> I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
> Sons. I'm in the middle of a standard argument on this issue and
> safety isn't convincing my opponents - deprication might.
>

Sorry to disappoint you. No deprecation on that one.

V

In this context, deprecation means 'frowned upon' not 'no longer
supported'.


In what context?


Take out your dictionary, V and look up the meaning of the word.


What meaning of what word? Stop playing your moronic games. You
said "this context". I asked which context you mean. You're now
suggesting looking in the dictionary. Are you challenged? Can you
simply answer the question asked?
The OP specifically asked about deprecation of C-style casts in the
Standard. There is none. The Standard does not contain any human
emotion or any judgement. It cannot. Nothing is "frowned upon" in
the Standard. > So in this sense, they are deprecated. Clearly their
addition to the language implied that their use, in most cases, was
preferred to C style casts.


Addition of what to which language?


Well we're not talking about Ada are we? Probably C++ - what do you
think?


I think when we talk about _C_-style casts, C++ _and_ C are both fair
game. What are you talking about? Dictionaries? English?

V
Feb 1 '06 #11
> Interestingly, Stroustrup also refers to C style casts as deprecated in
the C++ Programming Language, Special Edition, 2000, pp 818-819


People, lets not make false assumptions, thereby misleading others.
Stroustrup makes no such statement, reference or implication in
relation to C style casts. What he states is that they "should have
been deprecated when the new-style casts were introduced" and that the
new style casts should be preferred for reasons we know.

Regards,

Michael

Feb 1 '06 #12
Victor Bazarov wrote:
dakka" <"news at electro dot mine dot nu wrote:
Victor Bazarov wrote:
Dakka wrote:
Victor Bazarov wrote:

> ro**********@gm ail.com wrote:
>
>> Where is it in the standard that C style casts are labeled
>> depricated?
>
> Deprecated? Nowhere. 5.4 describes the explicit type conversion
> and what
> it means.
>
>> I read that on a lot of websites but I can't find it in the
>> standard.
>
> Because it's not there. What web site claims that it's
> deprecated? Can you post a link?
>
>> I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
>> Sons. I'm in the middle of a standard argument on this issue and
>> safety isn't convincing my opponents - deprication might.
>>
> Sorry to disappoint you. No deprecation on that one.
>
> V
In this context, deprecation means 'frowned upon' not 'no longer
supported'.
In what context?

Take out your dictionary, V and look up the meaning of the word.


What meaning of what word? Stop playing your moronic games. You
said "this context". I asked which context you mean. You're now
suggesting looking in the dictionary. Are you challenged? Can you
simply answer the question asked?


Ho hum. In the context that the original poster queried - that being why
he had seen C style casts being referred to as deprecated in C++. As for
the rest of your hotheaded guff.... yawn.
The OP specifically asked about deprecation of C-style casts in the
Standard. There is none. The Standard does not contain any human
emotion or any judgement. It cannot. Nothing is "frowned upon" in
the Standard. > So in this sense, they are deprecated. Clearly their
addition to the language implied that their use, in most cases, was
preferred to C style casts.
Addition of what to which language?

Well we're not talking about Ada are we? Probably C++ - what do you
think?


I think when we talk about _C_-style casts, C++ _and_ C are both fair
game. What are you talking about? Dictionaries? English?

V

Not in a C++ newsgroup they're not. I think its pretty clear what I
meant. For reasons only known to yourself you seem to think otherwise.
--dakka
Feb 1 '06 #13
mi************* @yahoo.com wrote:
Interestingly, Stroustrup also refers to C style casts as deprecated in
the C++ Programming Language, Special Edition, 2000, pp 818-819


People, lets not make false assumptions, thereby misleading others.
Stroustrup makes no such statement, reference or implication in
relation to C style casts. What he states is that they "should have
been deprecated when the new-style casts were introduced" and that the
new style casts should be preferred for reasons we know.

Regards,

Michael

Um nothing misleading there. Can't find the quote you cited though. He
does say
".. the new-style casts should be preferred because because they are
more explicit and more visible".

He doesn't say that the committee referred to them as deprecated but he
does express his *own* opinion that they should be. That was all I was
pointing out. However this statement appears in his book under the heading

B.2.3 Deprecated Features.

Regardless of whether the committee used the word deprecated or not, it
is clearly implied that they are. Lets just wait and see what comes in
c++0x.
--dakka
Feb 1 '06 #14
Well, maybe, it's in the deprecated section and he states that the
C-style casts should have been deprecated when the new ones were
introduced but isn't explicit about whether the old casts actually
were at the time of writing. However, it seems from the comments by
others above that the committee has not deprecated them. I don't have a
copy of the standard to reference so I wouldn't know.

Regards,

Michael

Feb 1 '06 #15
<mi************ *@yahoo.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com
Well, maybe, it's in the deprecated section and he states that the
C-style casts should have been deprecated when the new ones were
introduced but isn't explicit about whether the old casts actually
were at the time of writing. However, it seems from the comments by
others above that the committee has not deprecated them. I don't have
a copy of the standard to reference so I wouldn't know.


You are conceding ground you should not. Stroustrup does *not* say C-style
casts are deprecated and on any reasonable interpretation says the opposite.

In the same section he explicitly states that "The use of static to indicate
'local to translation unit' is deprecated". Likewise: "The implicit
conversion of string literal to a (non-const) char * is deprecated."

When by contrast he says "C-style casts *should* have been deprecated" (my
emphasis), he is clearly telling the reader that they have not been.

--
John Carson
Feb 1 '06 #16
Dakka wrote:

In this context, deprecation means 'frowned upon' not 'no longer
supported'.


In this context (i.e. standard C++) deprecated means that the C++
language definition says they are deprecated, which in turn means that
they might be removed from a future standard.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Feb 1 '06 #17
ro**********@gm ail.com wrote:

Perhaps it is in an addendum or something?


Perhaps it doesn't exist, and various websites by authors with varying
degrees of actual knowledge who claim otherwise are simply wrong. Lots
of people saying something doesn't make it true.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Feb 1 '06 #18
John Carson wrote:
You are conceding ground you should not.


I haven't conceded anything. My initial stance is clear in my first
post. My second post is based on rereading the text and questioning the
nature of the comments.

Anyway, the idea is to avoid using C-style casts. Bottom line, if they
are removed from the language in future, then whoever takes that advice
will not be impacted.

Regards,

Michael

Feb 2 '06 #19
Tom
Heck, two days ago I didn't even know what a C-style cast was.
Just stumbled across the following.

=============== ===========

http://www.freshsources.com/newcpp.html

Old-Style Casts. Old C-style casts are dangerous and ugly, but
sometimes a programmer's got to do what a programmer's got to do.
Unfortunately, programmers occasionally do the wrong thing. The
new-style C++ casts are superior to C-style casts because they

explicitly advertise the type of cast being performed
disallow any type of conversion other than the one requested, and
stand out in code inspections because of their noticeable syntax

For example, the expression
p = reinterpret_cas t<char*>(0x00f0 x10a)

is much more likely to draw a reader's attention than
p = (char*)(0x00f0x 10a)

Furthermore, using static_cast here instead of reinterpret_cas t would
fail, since the former only converts between related types. For now,
old-style casts are only deprecated, since otherwise too much existing
code would break, but watch out! Five years from now they're probably
going away.
=============== ===========

there's that deprecated word ^^

added that to my vocabulary last two days too.

dep·re·cate

TRANSITIVE VERB:
de·pre·cat·ed , de·pre·cat·ing , de·pre·cates
1) To express disapproval of; deplore.
2) To belittle; depreciate.

Feb 2 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
2559
by: Steven T. Hatton | last post by:
The code shown below is an example from the Coin3D documentation. I believe the use of the C-style cast is safe under the circumstances, but from what I've been exposed to (TC++PL(SE)), I would favor using a static_cast. Is there any technical reason to favor the C-style over a static_cast? http://doc.coin3d.org/Coin/index.html void foo(SoNode * node) { if (node->getTypeId() == SoFile::getClassTypeId()) {
15
1739
by: Christopher Benson-Manica | last post by:
If you had an unsigned int that needed to be cast to a const myClass*, would you use const myClass* a=reinterpret_cast<const myClass*>(my_val); or const myClass* a=(const myClass*)myVal; ?
3
1475
by: Howard | last post by:
Hi, I am maintaining a lot of code that is rife with C-style casts. I've seen a lot of comments that one should not use C-style casts at all. But I'm wondering what harm there could be in doing so with the built-in types. For example, if you have a long which needs to be passed to a function as an unsigned long, or a char* that needs to be passed as an unsigned char*, or an unsigned int that needs to be passed as a long, isn't it...
1
1395
by: Roy Smith | last post by:
I've got about 100 KLOC in which I want to find any uses of old C-style casts. Are there any good tools for this? Has anybody come up with a regex which does a decent job of finding them, or are there better ways to do it?
3
2311
by: Neil Zanella | last post by:
Hello, I would like to ask the following question concerning the C# as operator. I would like to know whether the difference between using a C-style cast such as double x = 0; float y = (double) x; and using the as operator is simply that as works on references rather
11
18275
by: esuvs81 | last post by:
Hi all. In short, is there any performance difference between: float f = 10.0f; int i = static_cast<int>(f); and float f = 10.0f; int i = int(f);
2
1385
by: Noah Roberts | last post by:
I have a class, that inherits from a class that inherits virtually from another class. I have a breakdown occuring and it is not wrt the virtually inherited class but one of the other MIed pure virtual classes. I get this in my call stack at the point of explosion: Flo.exe!DDocument::Dispatch(DFZone * ptr=0x0298d260) Line 94 + 0x32 bytes C++ Flo.exe!DDocument::Dispatch(DFZone * __A0=0x0298d260) + 0x2f
5
5931
by: brekehan | last post by:
I've always been a little sketchy on the differences between static, dynamic, and reinterpret casting. I am looking to clean up the following block by using C++ casting instead of the C style casting. from what I am reading, I should use reinterpret cast in this situation, is that correct? Why does static and dynamic casting fail me? // please excuse the windows types, it is necessary in this code, // but the question remains C++ related
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.