From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4EDC13842337; Tue, 6 Dec 2022 18:27:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EDC13842337 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670351244; bh=g4F/Qwh54YWv0TEXQLw5/XdhVPIqrrVABN+PaSBcF/0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=emeDo61/cVf8oprGH0ze6dajVh2xhH8jcNkLhkVRlc+BfF3f82UKv4XErHWn1T1Zp QuJpaTEFcg3nDdG2fUy2WMY6EPRbtZfeGADJo7hJ/nN36k27a5l3BCZM8ywleMzJrc WjxsyzxO5a8UitFkkF37atOUzRKXLs2nwmw6EXeg= From: "david.faust at oracle dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david.faust at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107843 --- Comment #1 from David Faust --- 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 =3D 0, E_BAR =3D 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 =E2=80=98bar_enum=E2=80=99: enumcast.c:10:20: error: incompatible type for argument 1 of =E2=80=98foo_e= num=E2=80=99 10 | return foo_enum ((void *) e); | ^~~~~~~~~~ | | | void * enumcast.c:7:22: note: expected =E2=80=98enum E=E2=80=99 but argument is of= type =E2=80=98void *=E2=80=99 7 | int foo_enum (enum E e); | ~~~~~~~^ enumcast.c: In function =E2=80=98bar_int=E2=80=99: 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 =E2=80=98foo_int=E2=80=99 = makes integer from pointer without a cast [-Wint-conversion] 16 | return foo_int ((void *) x); | ^~~~~~~~~~ | | | void * enumcast.c:13:18: note: expected =E2=80=98int=E2=80=99 but argument is of t= ype =E2=80=98void *=E2=80=99 13 | int foo_int (int x); | ~~~~^ $ clang -c enumcast.c -o enumcast.o enumcast.c:10:20: warning: incompatible pointer to integer conversion passi= ng '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 passi= ng '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.=