[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2019-08-16 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Marek Polacek  ---
Done.

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2019-08-16 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

--- Comment #5 from Marek Polacek  ---
Author: mpolacek
Date: Fri Aug 16 20:40:36 2019
New Revision: 274587

URL: https://gcc.gnu.org/viewcvs?rev=274587=gcc=rev
Log:
PR c++/85827
g++.dg/cpp1z/constexpr-if29.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C
Modified:
trunk/gcc/cp/ChangeLog

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2019-08-16 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #4 from Marek Polacek  ---
This particular problem was fixed in r269433, because the condition is not
dependent.  I'll add the test.  For another problem not fixed by this rev see
PR81676.

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2018-05-18 Thread kretz at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

--- Comment #3 from Matthias Kretz  ---
But macros are different. They remove the code before the C++ parser sees it
(at least as-if). One great improvement of constexpr-if over macros is that all
the other branches are parsed and their syntax checked. E.g. it requires the
mentioned names to exist. This doesn't compile (cf.
https://godbolt.org/g/iCRPDv):

#ifdef HAVE_FOO
constexpr bool have_foo = true;
void foo();
#else
constexpr bool have_foo = false;
#endif

void f() {
  if constexpr (have_foo) {
foo();
  }
}

So, the frontend parses all branches anyway. It should be able to see that _2
and _3 are referenced in f<1>().

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2018-05-18 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

--- Comment #2 from Marc Glisse  ---
I think that's going to be hard. The same issue always existed with macros. The
whole point of "if constexpr" is not to look at the other branches, as they may
not even compile. Sure, some minimal "safe" attempt at looking at those
branches would be possible, but I am not sure it is worth the trouble.

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2018-05-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-05-18
 Ever confirmed|0   |1

[Bug c++/85827] false positive for -Wunused-but-set-variable because of constexpr-if

2018-05-18 Thread kretz at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

--- Comment #1 from Matthias Kretz  ---
Same issue for -Wunused-variable