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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] detect incompatible aliases (PR c/81854)


On 08/18/2017 07:10 AM, Jonathan Wakely wrote:
On 17/08/17 21:21 -0600, Martin Sebor wrote:
Joseph, while looking into implementing enhancement your request
pr81824 I noticed that GCC silently accepts incompatible alias
declarations (pr81854) so as sort of a proof-concept for the
former I enhanced the checking already done for other kinds of
incompatibilities to also detect those mentioned in the latter
bug.  Attached is this patch, tested on x85_64-linux.

Jonathan, the patch requires suppressing the warning in libstdc++
compatibility symbol definitions in compatibility.cc.  I couldn't
find a way to do it without the suppression but I'd be happy to
try again if you have an idea for how.

Doing it that way is fine, but ...

diff --git a/libstdc++-v3/src/c++98/compatibility.cc
b/libstdc++-v3/src/c++98/compatibility.cc
index 381f4c4..5f56b9e 100644
--- a/libstdc++-v3/src/c++98/compatibility.cc
+++ b/libstdc++-v3/src/c++98/compatibility.cc
@@ -213,6 +213,11 @@ _ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
 */

+// Disable warning about declaring aliases between functions with
+// incompatible types.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wattributes"
+

Could this be moved closer to the point where it's needed?

It's not needed until after line 361, right?

Sure.  The other possibility that I forgot to mention is to
declare the alias without a prototype, which in C++ looks
like this:

  void foo (...);

The patch would then look like this.  Do you have a preference
between these two approaches?

Martin

diff --git a/libstdc++-v3/src/c++98/compatibility.cc b/libstdc++-v3/src/c++98/compatibility.cc
index 381f4c4..b49a5ca 100644
--- a/libstdc++-v3/src/c++98/compatibility.cc
+++ b/libstdc++-v3/src/c++98/compatibility.cc
@@ -367,13 +367,13 @@ _GLIBCXX_END_NAMESPACE_VERSION

 #define _GLIBCXX_3_4_SYMVER(XXname, name) \
    extern "C" void \
-   _X##name() \
+   _X##name(...) \
    __attribute__ ((alias(#XXname))); \
    asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");

 #define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
    extern "C" void \
-   _Y##name() \
+   _Y##name(...) \
    __attribute__ ((alias(#XXname))); \
    asm (".symver " "_Y" #name  "," #name "@@GLIBCXX_3.4.5");



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