This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

[PATCH] Fix aliasing violation tst-rec-dlopen


Some GCC versions warn about this.  It's a clear misuse (presumably to
avoid writing down the funny function pointer type), so I propose to fix
this, instead of assuming that GCC will do the right thing.
From f7bccd08a155d0b948136cfb7382e575119619a5 Mon Sep 17 00:00:00 2001
Message-Id: <f7bccd08a155d0b948136cfb7382e575119619a5.1450169364.git.fweimer@redhat.com>
From: Florian Weimer <fweimer@redhat.com>
Date: Tue, 15 Dec 2015 09:49:17 +0100
Subject: [PATCH] Fix aliasing violation in tst-rec-dlopen
To: libc-alpha@sourceware.org

---
 ChangeLog              | 5 +++++
 dlfcn/tst-rec-dlopen.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 81e5791..a24ac8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-15  Florian Weimer  <fweimer@redhat.com>
+
+	* dlfcn/tst-rec-dlopen.c (call_func): Cast dlsym result, fixing an
+	aliasing violation.
+
 2015-12-10  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Split large string section; add truncation advice
diff --git a/dlfcn/tst-rec-dlopen.c b/dlfcn/tst-rec-dlopen.c
index 01353fb..1ab7aa9 100644
--- a/dlfcn/tst-rec-dlopen.c
+++ b/dlfcn/tst-rec-dlopen.c
@@ -57,7 +57,7 @@ call_func (const char *dso_name, const char *func_name)
   dlerror ();
 
   /* Lookup func.  */
-  *(void **) (&func) = dlsym (dso, func_name);
+  func = (int (*) (void)) dlsym (dso, func_name);
   if (func == NULL)
     {
       err = dlerror ();
-- 
2.4.3


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