Bug 78987 - Wrong location of a binary expression for -Waddress
Summary: Wrong location of a binary expression for -Waddress
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Waddress
  Show dependency treegraph
 
Reported: 2017-01-04 16:22 UTC by Martin Liška
Modified: 2021-11-22 16:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-01-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-01-04 16:22:41 UTC
Starting from 4.8, where location description was added.

$ cat /tmp/wrong-conditions.c 
void foo() {}
void bar() {}
void baz() {}

int main2(int argc, int argc2)
{
  if (foo && bar && baz)
    return 1;

  return 0;
}

$ ./xgcc -B. /tmp/wrong-conditions.c -c -Wall
/tmp/wrong-conditions.c: In function ‘main2’:
/tmp/wrong-conditions.c:7:7: warning: the address of ‘foo’ will always evaluate as ‘true’ [-Waddress]
   if (foo && bar && baz)
       ^~~
/tmp/wrong-conditions.c:7:11: warning: the address of ‘bar’ will always evaluate as ‘true’ [-Waddress]
   if (foo && bar && baz)
           ^~
/tmp/wrong-conditions.c:7:18: warning: the address of ‘baz’ will always evaluate as ‘true’ [-Waddress]
   if (foo && bar && baz)
                  ^~

Location of the first is correct, last 2 are wrong.
Comment 1 Martin Liška 2017-01-04 16:25:21 UTC
C++ related issue: PR78988.
Comment 2 Martin Sebor 2017-01-05 03:06:21 UTC
Also confirmed, like bug 78988.  Should these two bugs be one and the same or is the location information set separately by each front end?
Comment 3 Martin Liška 2018-11-02 07:52:01 UTC
David will you be interested in the PR?