public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99317] Missed warning Date: Tue, 02 Mar 2021 16:38:00 +0000 [thread overview] Message-ID: <bug-99317-4-eMdY4dRxKn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99317-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99317 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Resolution|--- |WONTFIX Status|UNCONFIRMED |RESOLVED See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=44209 --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- To expand on Andrew's comment: The C rules specify the type of the result of operator ?: when either of the second and third operands is a pointer to void, but they do no specify the result type when the operands are pointers to incompatible types (like int* and float*). The warning points out the latter. The C++ rules, OTOH, are more restrictive and make the ?: expression valid only when the types of the arguments can be implicitly converted to one another. Since in C++ a pointer to void isn't implicitly convertible to a pointer to an object type all the expressions in the test case are invalid. In C mode, the -Wc++-compat option helps detect C/C++ incompatibilities and detects this problem (below). So with that, since the problem is diagnosed under the right option, I think this report can be resolved as WONTFIX. (That the warning in comment #0 is issued unconditionally and not under the control of a specific option, is a separate problem tracked in in bug 44209.) $ gcc -S -Wall -Wc++-compat pr99317.c pr99317.c: In function ‘foo’: pr99317.c:3:17: warning: request for implicit conversion from ‘void *’ to ‘float *’ not permitted in C++ [-Wc++-compat] 3 | float * f = v; | ^ pr99317.c:4:15: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 4 | int * i = w; | ^ pr99317.c:5:19: warning: pointer type mismatch in conditional expression 5 | return (x ? f : i); | ^ pr99317.c:5:19: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 5 | return (x ? f : i); | ~~~~~~~^~~~ pr99317.c: In function ‘foo1’: pr99317.c:10:17: warning: request for implicit conversion from ‘void *’ to ‘float *’ not permitted in C++ [-Wc++-compat] 10 | float * f = v; | ^ pr99317.c:11:15: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 11 | int * i = w; | ^ pr99317.c:12:19: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 12 | return (1 ? f : (void *)i); | ~~~~~~~^~~~~~~~~~~~ pr99317.c: In function ‘bar’: pr99317.c:16:17: warning: request for implicit conversion from ‘void *’ to ‘float *’ not permitted in C++ [-Wc++-compat] 16 | float * f = v; | ^ pr99317.c:17:15: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 17 | int * i = w; | ^ pr99317.c:18:19: warning: request for implicit conversion from ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat] 18 | return (x ? f : (void *)i); | ~~~~~~~^~~~~~~~~~~~
prev parent reply other threads:[~2021-03-02 16:38 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-01 14:25 [Bug c/99317] New: " pj at hugeone dot co.uk 2021-03-01 17:20 ` [Bug c/99317] " pinskia at gcc dot gnu.org 2021-03-02 2:01 ` pj at hugeone dot co.uk 2021-03-02 2:28 ` pinskia at gcc dot gnu.org 2021-03-02 16:38 ` msebor at gcc dot gnu.org [this message]
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-99317-4-eMdY4dRxKn@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).