[Bug c++/85963] [8/9 Regression] false positive "set but not used" warning [-Wunused-but-set-variable]

2018-06-11 Thread mcortez at airpost dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85963

--- Comment #3 from Michael Cortez  ---
Created attachment 44257
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44257=edit
bug.cpp

simplified test case

[Bug c++/85963] [8/9 Regression] false positive "set but not used" warning [-Wunused-but-set-variable]

2018-06-11 Thread mcortez at airpost dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85963

Michael Cortez  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Michael Cortez  ---
Simplified test case:

template
inline void foo(T& x) {
  const bool bar = true;
  x = bar ? (x*x) : T(0);
  }

int main() {
  double x = 123.4;
  foo(x);
  return 0;
  }

g++ bug.cpp -Wall -O2
bug.cpp: In instantiation of ‘void foo(T&) [with T = double]’:
bug.cpp:9:8:   required from here
bug.cpp:3:14: warning: variable ‘bar’ set but not used
[-Wunused-but-set-variable]
   const bool bar = true;
  ^~~

[Bug c++/82728] [8 regression] Incorrect -Wunused-but-set-variable warning with a const

2018-05-28 Thread mcortez at airpost dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82728

Michael Cortez  changed:

   What|Removed |Added

 CC||mcortez at airpost dot net

--- Comment #6 from Michael Cortez  ---
(In reply to Jason Merrill from comment #5)
> Fixed.

It seems to be broken again on gcc 8.1:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85963

[Bug c++/85963] New: false positive "set but not used" warning [-Wunused-but-set-variable]

2018-05-28 Thread mcortez at airpost dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85963

Bug ID: 85963
   Summary: false positive "set but not used" warning
[-Wunused-but-set-variable]
   Product: gcc
   Version: 8.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcortez at airpost dot net
  Target Milestone: ---

Related to, but not fixed by:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82728
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82799

Getting an annoying false positive "set but not used" warning when compiling
with -Wall

g++ (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1) on Fedora 28.  gcc was updated to
whatever the latest version is available in Fedora 28 update repos.

Reduced test case:

template
struct foo {
  T val, alpha;
  foo() : val(0), alpha(0) {}
  };

template
inline void bar(const foo& A, const foo& B, foo& C) {
  const bool use_alpha = true;
  const Talpha = use_alpha ? (A.alpha * B.alpha) : T(0);

  C.val   = A.val * B.val;
  C.alpha = alpha;
  }


int main() {
  foo A,B,C;

  bar(A,B,C);

  return 0;
  }


g++ gccwarn.cpp -o gccwarn -Wall -O2
gccwarn.cpp: In instantiation of ‘void bar(const foo&, const foo&,
foo&) [with T = double]’:
gccwarn.cpp:21:12:   required from here
gccwarn.cpp:10:14: warning: variable ‘use_alpha’ set but not used
[-Wunused-but-set-variable]
   const bool use_alpha = true;
  ^