public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2
@ 2022-11-23 17:37 james.hilliard1 at gmail dot com
2022-12-06 18:27 ` [Bug target/107843] " david.faust at oracle dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: james.hilliard1 at gmail dot com @ 2022-11-23 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107843
Bug ID: 107843
Summary: error: incompatible type for argument in
___bpf_ctx_cast2
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: james.hilliard1 at gmail dot com
Target Milestone: ---
I'm seeing this error which does not occur in llvm for a bpf test(bpf_cubic.c)
in bpf-next:
In file included from
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_tcp_helpers.h:9,
from progs/bpf_cubic.c:20:
progs/bpf_cubic.c: In function 'bpf_cubic_cwnd_event':
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:399:63:
error: incompatible type for argument 3 of '____bpf_cubic_cwnd_event'
399 | #define ___bpf_ctx_cast2(x, args...) ___bpf_ctx_cast1(args), (void
*)ctx[1]
|
^~~~~~~~~~~~~~
| |
| void *
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_helpers.h:187:29:
note: in expansion of macro '___bpf_ctx_cast2'
187 | #define ___bpf_concat(a, b) a ## b
| ^
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_helpers.h:190:29:
note: in expansion of macro '___bpf_concat'
190 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
| ^~~~~~~~~~~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:410:39:
note: in expansion of macro '___bpf_apply'
410 | #define ___bpf_ctx_cast(args...) ___bpf_apply(___bpf_ctx_cast,
___bpf_narg(args))(args)
| ^~~~~~~~~~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:435:27:
note: in expansion of macro '___bpf_ctx_cast'
435 | return ____##name(___bpf_ctx_cast(args));
\
| ^~~~~~~~~~~~~~~
progs/bpf_cubic.c:189:6: note: in expansion of macro 'BPF_PROG'
189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
| ^~~~~~~~
progs/bpf_cubic.c:189:72: note: expected 'enum tcp_ca_event' but argument is of
type 'void *'
189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
|
~~~~~~~~~~~~~~~~~~^~~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:430:39:
note: in definition of macro 'BPF_PROG'
430 | ____##name(unsigned long long *ctx, ##args);
\
| ^~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:435:16:
error: 'return' with a value, in function returning void [-Werror]
435 | return ____##name(___bpf_ctx_cast(args));
\
| ^~~~
progs/bpf_cubic.c:189:6: note: in expansion of macro 'BPF_PROG'
189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
| ^~~~~~~~
progs/bpf_cubic.c:189:15: note: declared here
189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
| ^~~~~~~~~~~~~~~~~~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:431:17:
note: in definition of macro 'BPF_PROG'
431 | typeof(name(0)) name(unsigned long long *ctx)
\
|
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/107843] error: incompatible type for argument in ___bpf_ctx_cast2
2022-11-23 17:37 [Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2 james.hilliard1 at gmail dot com
@ 2022-12-06 18:27 ` david.faust at oracle dot com
2023-01-06 14:28 ` jemarch at gcc dot gnu.org
2023-01-10 9:15 ` jemarch at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: david.faust at oracle dot com @ 2022-12-06 18:27 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/107843] error: incompatible type for argument in ___bpf_ctx_cast2
2022-11-23 17:37 [Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2 james.hilliard1 at gmail dot com
2022-12-06 18:27 ` [Bug target/107843] " david.faust at oracle dot com
@ 2023-01-06 14:28 ` jemarch at gcc dot gnu.org
2023-01-10 9:15 ` jemarch at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jemarch at gcc dot gnu.org @ 2023-01-06 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107843
Jose E. Marchesi <jemarch at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-01-06
Ever confirmed|0 |1
--- Comment #2 from Jose E. Marchesi <jemarch at gcc dot gnu.org> ---
Opened a clang/llvm bug for this, to see if they would consider turning the
warning into an error to converge with GCC's behavior.
https://github.com/llvm/llvm-project/issues/59858
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/107843] error: incompatible type for argument in ___bpf_ctx_cast2
2022-11-23 17:37 [Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2 james.hilliard1 at gmail dot com
2022-12-06 18:27 ` [Bug target/107843] " david.faust at oracle dot com
2023-01-06 14:28 ` jemarch at gcc dot gnu.org
@ 2023-01-10 9:15 ` jemarch at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jemarch at gcc dot gnu.org @ 2023-01-10 9:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107843
Jose E. Marchesi <jemarch at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #3 from Jose E. Marchesi <jemarch at gcc dot gnu.org> ---
clang/llvm confirms that clang 15 behaves like GCC, emitting the same error.
So I am closing this issue.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-10 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 17:37 [Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2 james.hilliard1 at gmail dot com
2022-12-06 18:27 ` [Bug target/107843] " david.faust at oracle dot com
2023-01-06 14:28 ` jemarch at gcc dot gnu.org
2023-01-10 9:15 ` jemarch at gcc dot gnu.org
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).