This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-Wold-style-cast and system headers


-Wold-style-cast is less useful than it could be because of system headers.

For instance, most flavors of ctype.h (and cctype) do index off an array
using (unsigned char) c] for an index.

Evidently, this is a safe cast, that could be converted to 
static_cast<unsigned char>(c)
but I don't quite know how to deal with that more generally.

Part of the problem is that C++ casts will look ugly to some, even using
such a construct as

#ifdef __GNUG__
#define __static_cast(type)(value)	static_cast<type>(value)
#else
#define __static_cast(type)(value)	((type)(value))
#endif

so that I will probably have trouble getting something like this in the
OpenBSD includes.

The other trouble is how to add such patterns to fixincludes ? 
Especially as system includes will probably include dangerous casts as well.

so I'm looking for a strategy to deal with that: add more magic keywords to 
g++, such as a cast that wouldn't warn when used for system includes,
dealing with fix_includes, or getting cast warnings conditional.

-- 
	Marc Espie		
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]