public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "david.faust at oracle dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/107843] error: incompatible type for argument in ___bpf_ctx_cast2 Date: Tue, 06 Dec 2022 18:27:23 +0000 [thread overview] Message-ID: <bug-107843-4-lCjn0GwauM@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107843-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107843 --- Comment #1 from David Faust <david.faust at oracle dot com> --- Looks like this is an issue with passing void* where an enum type is expected in a function call. This is not specific to the BPF backend. Not entirely clear to me whether this is expected or a bug, but it does differ from llvm behavior. Reproducer below, tried with a few gccs, same behavior: today (6 Dec 2022)'s master 81476bc4f4a20bcf3af7ac2548c2322d48499402 gcc-12 (Debian 12.2.0-9) 12.2.0 gcc-10 (Debian 10.4.0-5) 10.4.0 gcc-8 (Debian 8.4.0-7) 8.4.0 $ cat enumcast.c enum E { E_FOO = 0, E_BAR = 1, }; int foo_enum (enum E e); int bar_enum (enum E e) { return foo_enum ((void *) e); } int foo_int (int x); int bar_int (int x) { return foo_int ((void *) x); } $ gcc -c enumcast.c -o enumcast.o enumcast.c: In function ‘bar_enum’: enumcast.c:10:20: error: incompatible type for argument 1 of ‘foo_enum’ 10 | return foo_enum ((void *) e); | ^~~~~~~~~~ | | | void * enumcast.c:7:22: note: expected ‘enum E’ but argument is of type ‘void *’ 7 | int foo_enum (enum E e); | ~~~~~~~^ enumcast.c: In function ‘bar_int’: enumcast.c:16:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 16 | return foo_int ((void *) x); | ^ enumcast.c:16:19: warning: passing argument 1 of ‘foo_int’ makes integer from pointer without a cast [-Wint-conversion] 16 | return foo_int ((void *) x); | ^~~~~~~~~~ | | | void * enumcast.c:13:18: note: expected ‘int’ but argument is of type ‘void *’ 13 | int foo_int (int x); | ~~~~^ $ clang -c enumcast.c -o enumcast.o enumcast.c:10:20: warning: incompatible pointer to integer conversion passing 'void *' to parameter of type 'enum E' [-Wint-conversion] return foo_enum ((void *) e); ^~~~~~~~~~ enumcast.c:7:22: note: passing argument to parameter 'e' here int foo_enum (enum E e); ^ enumcast.c:16:19: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast] return foo_int ((void *) x); ^~~~~~~~~~ enumcast.c:16:19: warning: incompatible pointer to integer conversion passing 'void *' to parameter of type 'int' [-Wint-conversion] return foo_int ((void *) x); ^~~~~~~~~~ enumcast.c:13:18: note: passing argument to parameter 'x' here int foo_int (int x); ^ 3 warnings generated.
next prev parent reply other threads:[~2022-12-06 18:27 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-23 17:37 [Bug target/107843] New: " james.hilliard1 at gmail dot com 2022-12-06 18:27 ` david.faust at oracle dot com [this message] 2023-01-06 14:28 ` [Bug target/107843] " jemarch at gcc dot gnu.org 2023-01-10 9:15 ` jemarch at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107843-4-lCjn0GwauM@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).