public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99317] New: Missed warning
@ 2021-03-01 14:25 pj at hugeone dot co.uk
  2021-03-01 17:20 ` [Bug c/99317] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pj at hugeone dot co.uk @ 2021-03-01 14:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99317

            Bug ID: 99317
           Summary: Missed warning
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pj at hugeone dot co.uk
  Target Milestone: ---

The code:

int *foo(void *v, void *w, int x) {
    float * f = v;
    int * i = w;
    return (x ? f : i); 
}


int *foo1(void *v, void *w, int x) {
    float * f = v;
    int * i = w;
    return (1 ? f : (void *)i); 
}

int *bar(void *v, void *w, int x) {
    float * f = v;
    int * i = w;
    return (x ? f : (void *)i); 
}

Function foo correctly emits the warning:

source>: In function 'foo':
<source>:7:19: warning: pointer type mismatch in conditional expression
    7 |     return (x ? f : i);
      |                   ^

Casting removes that warming even in the trivial foo1 example.

https://godbolt.org/z/ozsPPY

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-02 16:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 14:25 [Bug c/99317] New: Missed warning 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 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).