public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26030] New: C-style casts and function-style casts
@ 2006-01-30 13:11 wolfgang dot roehrl at gi-de dot com
2006-01-30 13:52 ` [Bug c++/26030] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: wolfgang dot roehrl at gi-de dot com @ 2006-01-30 13:11 UTC (permalink / raw)
To: gcc-bugs
Dear all,
I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor.
Used invokation line for the GNU C++ compiler:
ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
-fmerge-templates -mmultiple -mno-string -mstrict-align -O3
-fno-exceptions -fno-rtti -fno-builtin-printf
-I<different include paths>
-D<differen #define's>
X.CPP -oX.O
// file X.CPP
void f (int);
typedef int* I;
I f0 () { return static_cast<I>(f); } <--- line 5
I f1 () { return reinterpret_cast<I>(f); } <--- line 7
I f2 () { return (I)f; } // cast notation
I f3 () { return I(f); } // functional notation
The compiler gives the following error messages:
X.CPP: In function `int* f0()':
X.CPP:5: error: invalid static_cast from type `void ()(int)' to type `int*'
X.CPP: In function `int* f1()':
X.CPP:7: error: ISO C++ forbids casting between pointer-to-function and
pointer-to-object
I think the compiler should also reject the casts in f2() and f3():
- 5.4/5 states that the cast notation of explicit conversion performs only
the conversions of a const_cast<>, of a static_cast<>, of reinterpret_cast<>
and of certain combinations of those casts.
- 5.2.3/1 says that cast in f3() is equivalent to the cast in f2().
Kind regards
W. Roehrl
--
Summary: C-style casts and function-style casts
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wolfgang dot roehrl at gi-de dot com
GCC build triplet: sparc-sun-solaris2.5.1
GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26030
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/26030] C-style casts and function-style casts
2006-01-30 13:11 [Bug c++/26030] New: C-style casts and function-style casts wolfgang dot roehrl at gi-de dot com
@ 2006-01-30 13:52 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-30 13:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-30 13:52 -------
This is a dup of bug 10818. Note DR 195 is related to this case.
*** This bug has been marked as a duplicate of 10818 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26030
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-30 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-30 13:11 [Bug c++/26030] New: C-style casts and function-style casts wolfgang dot roehrl at gi-de dot com
2006-01-30 13:52 ` [Bug c++/26030] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).