This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ name mangling in C
- From: Florian Weimer <fweimer at redhat dot com>
- To: daniel at poradnik-webmastera dot com, gcc-help at gcc dot gnu dot org
- Date: Mon, 11 Aug 2014 13:29:20 +0200
- Subject: Re: C++ name mangling in C
- Authentication-results: sourceware.org; auth=none
- References: <20140809215057 dot Horde dot vyEDuGF06pHW1H_WOtKpyw1 at sirzooro dot prohost dot pl>
On 08/09/2014 09:50 PM, daniel@poradnik-webmastera.com wrote:
When this code is compiled using C++ compiler, such error will be
reported at linking phase as "undefined reference to 'test(int)'".
Unfortunately in C compilation and linking will succeed, so bug will
appear at runtime. But such bugs may be very hard to find.
If you have such issues in the code base, a conversion to C++ will be
very difficult and is unlikely to uncover all such issues. For example,
neither function return nor structure layout influence name mangling.
-flto should really warn about this, but it didn't with my tests (based
on GCC 4.8). Does anybody know what's going on there? How can GCC even
pretend to generate correct code in the face of such blatant typing
violations?
--
Florian Weimer / Red Hat Product Security