Demo for clang bug (demonstrated with version 3.4)
Based on this question on Stack Overflow.
===
It turns out that this isn't a bug; see Jens Gustedt's answer to the question.
Demo for clang bug (demonstrated with version 3.4)
Based on this question on Stack Overflow.
===
It turns out that this isn't a bug; see Jens Gustedt's answer to the question.
// http://stackoverflow.com/q/24743520/827263 | |
#include <stdio.h> | |
static void print_i(int i) { puts("int"); } | |
static void print_ip(int *i) { puts("int*"); } | |
#define print(num) _Generic((num), \ | |
int : print_i(num), \ | |
int* : print_ip(num)) | |
int main(void) { | |
int i = 10; | |
print(i); | |
print(&i); | |
} |
int | |
int* |
c.c:12:11: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with & [-Wint-conversion] | |
print(i); | |
^ | |
& | |
c.c:8:23: note: expanded from macro 'print' | |
int* : print_ip(num)) | |
^ | |
c.c:4:27: note: passing argument to parameter 'i' here | |
static void print_ip(int *i) { puts("int*"); } | |
^ | |
c.c:13:11: warning: incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove & [-Wint-conversion] | |
print(&i); | |
^~ | |
c.c:7:22: note: expanded from macro 'print' | |
int : print_i(num), \ | |
^ | |
c.c:3:25: note: passing argument to parameter 'i' here | |
static void print_i(int i) { puts("int"); } | |
^ | |
2 warnings generated. |