On Fri, Nov 09, 2018 at 11:34:48AM +0100, Dominique d'Humières wrote:
> Bootstrapping r265942 on darwin failed with
>
> In file included from
> /Applications/Xcode-6.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h:490,
> from ../../../work/libgomp/affinity-fmt.c:28:
> ../../../work/libgomp/affinity-fmt.c: In function 'gomp_display_affinity':
> ../../../work/libgomp/affinity-fmt.c:369:17: error: format '%x' expects
> argument of type 'unsigned int', but argument 5 has type 'long unsigned int'
> -Werror=format=]
> 369 | sprintf (buf, "0x%x", (uintptr_t) handle);
> | ^~~~~~ ~~~~~~~~~~~~~~~~~~
Weird, the above prints a line which just isn't there, line 369 is:
sprintf (buf, "0x%x", (int) handle);
not
sprintf (buf, "0x%x", (uintptr_t) handle);
What is pthread_t on your platform? An integral type (which one), pointer
or something different (e.g. an aggregate)?
I wonder if I shouldn't use __builtin_choose_expr to wrap it up and select
at compile time the only variant that applies.
Something like:
--- libgomp/affinity-fmt.c 2018-10-08 13:27:41.021061844 +0200
+++ libgomp/affinity-fmt.c 2018-11-09 12:01:17.048151087 +0100
@@ -356,37 +356,39 @@ gomp_display_affinity (char *buffer, siz
goto do_int;
case 'i':
#if defined(LIBGOMP_USE_PTHREADS) && defined(__GNUC__)
- /* Handle integral pthread_t. */
- if (__builtin_classify_type (handle) == 1)
- {
- char buf[3 * (sizeof (handle) + sizeof (int)) + 4];
-
- if (sizeof (handle) == sizeof (long))
- sprintf (buf, "0x%lx", (long) handle);
- else if (sizeof (handle) == sizeof (long long))
- sprintf (buf, "0x%llx", (long long) handle);
- else
- sprintf (buf, "0x%x", (int) handle);
- gomp_display_num (buffer, size, &ret, zero, right, sz, buf);
- break;
- }
- /* And pointer pthread_t. */
- else if (__builtin_classify_type (handle) == 5)
- {
- char buf[3 * (sizeof (uintptr_t) + sizeof (int)) + 4];
-
- if (sizeof (uintptr_t) == sizeof (long))
- sprintf (buf, "0x%lx", (long) (uintptr_t) handle);
- else if (sizeof (uintptr_t) == sizeof (long long))
- sprintf (buf, "0x%llx", (long long) (uintptr_t) handle);
- else
- sprintf (buf, "0x%x", (int) (uintptr_t) handle);
- gomp_display_num (buffer, size, &ret, zero, right, sz, buf);
- break;
- }
-#endif
+ {
+ char buf[3 * (sizeof (handle) + sizeof (uintptr_t) + sizeof (int))
+ + 4];
+ /* Handle integral pthread_t. */
+ __builtin_choose_expr (__builtin_classify_type (handle) == 1,
+ sizeof (handle) == sizeof (long)
+ ? sprintf (buf, "0x%lx", (long) handle)
+ : sizeof (handle) == sizeof (long long)
+ ? sprintf (buf, "0x%llx",
+ (long long) handle)
+ : sprintf (buf, "0x%x", (int) handle),
+ 0);
+ /* And pointer pthread_t. */
+ __builtin_choose_expr (__builtin_classify_type (handle) == 5,
+ sizeof (uintptr_t) == sizeof (long)
+ ? sprintf (buf, "0x%lx",
+ (long) (uintptr_t) handle)
+ : sizeof (uintptr_t) == sizeof (long long)
+ ? sprintf (buf, "0x%llx",
+ (long long) (uintptr_t) handle)
+ : sprintf (buf, "0x%x",
+ (int) (uintptr_t) handle),
+ 0);
+ if (__builtin_classify_type (handle) != 1
+ && __builtin_classify_type (handle) != 5)
+ strcpy (buf, "0");
+ gomp_display_num (buffer, size, &ret, zero, right, sz, buf);
+ break;
+ }
+#else
val = 0;
goto do_int;
+#endif
case 'A':
if (sz == (size_t) -1)
gomp_display_affinity_place (buffer, size, &ret,
Jakub