public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug regression/94436] New: incompatible-pointer-types warning with container_of @ 2020-04-01 9:55 npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:00 ` [Bug regression/94436] " pinskia at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: npfhrotynz-ptnqh.myvf at noclue dot notk.org @ 2020-04-01 9:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94436 Bug ID: 94436 Summary: incompatible-pointer-types warning with container_of Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: regression Assignee: unassigned at gcc dot gnu.org Reporter: npfhrotynz-ptnqh.myvf at noclue dot notk.org Target Milestone: --- Created attachment 48157 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48157&action=edit test program.c This looks like a regression in warnings: passing an argument straight from a container_of construct fails with incompatible type warning. In the attached code, the if 0'd implementation taken from the linux kernel works, but the other one also seen in the linux kernel (why do they have multiple implementations?!) produces the following warning: ------------ t.c: In function ‘main’: t.c:14:41: warning: passing argument 1 of ‘func’ from incompatible pointer type [-Wincompatible-pointer-types] 14 | #define container_of(ptr, type, member) (type *)((char *)(ptr) - (char *) &((type *)0)->member) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | char * t.c:24:14: note: in expansion of macro ‘container_of’ 24 | return func(container_of(&bar, struct foo, bar)); | ^~~~~~~~~~~~ t.c:17:22: note: expected ‘struct foo *’ but argument is of type ‘char *’ 17 | int func(struct foo* foo) { | ~~~~~~~~~~~~^~~ ------------- Here is -E preprocessed interesting line: return func((struct foo *)((char *)(&bar) - (char *) &((struct foo *)0)->bar)); For me the whole thing is cast with (struct foo*) so it should silence that warning as it used to do (tested with gcc 7.4.0 and gcc 9.2.0) In the case I'm looking at I could work around by using the other implementation, but I see that macro defined all the time so would be interested in seeing the old behaviour back. Thanks! ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug regression/94436] incompatible-pointer-types warning with container_of 2020-04-01 9:55 [Bug regression/94436] New: incompatible-pointer-types warning with container_of npfhrotynz-ptnqh.myvf at noclue dot notk.org @ 2020-04-01 10:00 ` pinskia at gcc dot gnu.org 2020-04-01 10:08 ` npfhrotynz-ptnqh.myvf at noclue dot notk.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2020-04-01 10:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94436 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I think this was fixed already. What git commit are you at? ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug regression/94436] incompatible-pointer-types warning with container_of 2020-04-01 9:55 [Bug regression/94436] New: incompatible-pointer-types warning with container_of npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:00 ` [Bug regression/94436] " pinskia at gcc dot gnu.org @ 2020-04-01 10:08 ` npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:13 ` jakub at gcc dot gnu.org 2020-04-01 12:33 ` [Bug middle-end/94436] " cvs-commit at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: npfhrotynz-ptnqh.myvf at noclue dot notk.org @ 2020-04-01 10:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94436 Dominique Martinet <npfhrotynz-ptnqh.myvf at noclue dot notk.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED --- Comment #2 from Dominique Martinet <npfhrotynz-ptnqh.myvf at noclue dot notk.org> --- Sorry I didn't check the latest git, I'm using whatever is shipped in fedora 32's gcc-10.0.1-0.9.fc32 . . . which I now see isn't even the latest ; and upgrading does fix this. Sorry for the noise! And thanks for fast reply. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug regression/94436] incompatible-pointer-types warning with container_of 2020-04-01 9:55 [Bug regression/94436] New: incompatible-pointer-types warning with container_of npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:00 ` [Bug regression/94436] " pinskia at gcc dot gnu.org 2020-04-01 10:08 ` npfhrotynz-ptnqh.myvf at noclue dot notk.org @ 2020-04-01 10:13 ` jakub at gcc dot gnu.org 2020-04-01 12:33 ` [Bug middle-end/94436] " cvs-commit at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2020-04-01 10:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94436 --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Indeed, this has been introduced with r10-7127-gcb99630f254aaec6591e0a200b79905b31d24eb3 and fixed with r10-7237-g4e3d3e40726e1b68bf52fa205c68495124ea60b8 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/94436] incompatible-pointer-types warning with container_of 2020-04-01 9:55 [Bug regression/94436] New: incompatible-pointer-types warning with container_of npfhrotynz-ptnqh.myvf at noclue dot notk.org ` (2 preceding siblings ...) 2020-04-01 10:13 ` jakub at gcc dot gnu.org @ 2020-04-01 12:33 ` cvs-commit at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2020-04-01 12:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94436 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:e899d4b71255b9ae096a7ecd31a61fc76f200019 commit r10-7496-ge899d4b71255b9ae096a7ecd31a61fc76f200019 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Apr 1 14:33:32 2020 +0200 Add testcase for already fixed PR [PR94436] 2020-04-01 Jakub Jelinek <jakub@redhat.com> PR middle-end/94436 * gcc.dg/pr94436.c: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-01 12:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-01 9:55 [Bug regression/94436] New: incompatible-pointer-types warning with container_of npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:00 ` [Bug regression/94436] " pinskia at gcc dot gnu.org 2020-04-01 10:08 ` npfhrotynz-ptnqh.myvf at noclue dot notk.org 2020-04-01 10:13 ` jakub at gcc dot gnu.org 2020-04-01 12:33 ` [Bug middle-end/94436] " cvs-commit 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).