[Bug c++/66256] noexcept evaluation done before end of class

2019-06-22 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #14 from Marek Polacek  ---
Fixed by r272586.

[Bug c++/66256] noexcept evaluation done before end of class

2019-06-22 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #13 from Marek Polacek  ---
Author: mpolacek
Date: Sat Jun 22 15:51:49 2019
New Revision: 272588

URL: https://gcc.gnu.org/viewcvs?rev=272588&root=gcc&view=rev
Log:
PR c++/66256
* g++.dg/cpp0x/noexcept54.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/noexcept54.C
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug c++/66256] noexcept evaluation done before end of class

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

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #12 from Marek Polacek  ---
(In reply to Jonathan Wakely from comment #10)
> Right, GCC's behaviour for comment 0, comment 7 and comment 8 is a bug.

My patch  fixes all
of these; mine.

[Bug c++/66256] noexcept evaluation done before end of class

2017-09-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Jonathan Wakely  changed:

   What|Removed |Added

 CC||serge.guelton@telecom-breta
   ||gne.eu

--- Comment #11 from Jonathan Wakely  ---
*** Bug 82311 has been marked as a duplicate of this bug. ***

[Bug c++/66256] noexcept evaluation done before end of class

2017-08-29 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #10 from Jonathan Wakely  ---
Right, GCC's behaviour for comment 0, comment 7 and comment 8 is a bug.

GCC's behaviour for comment 3 and comment 4 is not a bug.

[Bug c++/66256] noexcept evaluation done before end of class

2017-08-24 Thread david at doublewise dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #9 from David Stone  ---
Sorry, I misread the chain of comments, Jonathan Wakely's comment on gcc
correctly rejecting invalid code refers specifically to the decltype example.
Please ignore my previous comment, except that it captures the wording from the
standard that says that the test case for this bug should work.

[Bug c++/66256] noexcept evaluation done before end of class

2017-08-24 Thread david at doublewise dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

David Stone  changed:

   What|Removed |Added

 CC||david at doublewise dot net

--- Comment #8 from David Stone  ---
I do not believe that gcc is correct to reject this code. Consider

http://eel.is/c++draft/basic.scope.class#1

"The potential scope of a name declared in a class consists not only of the
declarative region following the name's point of declaration, but also of all
function bodies, default arguments, noexcept-specifiers, and
brace-or-equal-initializers of non-static data members in that class (including
such things in nested classes)."

That seems to state that this variable is in scope and thus this code should be
allowed.

As a second test case, this should also be accepted (same code, but with e put
in an unevaluated context instead of being static):


struct test
{
test() noexcept(noexcept(e)) {}
const bool e = false;
};

int main() {}




And also



struct test
{
test() noexcept(noexcept(e())) {}
const bool e() { return false; }
};

int main() {}

[Bug c++/66256] noexcept evaluation done before end of class

2017-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||accepts-invalid
   Last reconfirmed|2017-02-14 00:00:00 |2017-4-24
 CC||redi at gcc dot gnu.org

--- Comment #7 from Jonathan Wakely  ---
Accepts invalid testcase for the issue mentioned in comment 1:

void swap(int&, int&);

int& get();

struct pair {
  void swap(pair&) noexcept(noexcept(swap(get(), get( { }
};

[Bug c++/66256] noexcept evaluation done before end of class

2017-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Jonathan Wakely  changed:

   What|Removed |Added

 CC||barry.revzin at gmail dot com

--- Comment #6 from Jonathan Wakely  ---
*** Bug 70142 has been marked as a duplicate of this bug. ***

[Bug c++/66256] noexcept evaluation done before end of class

2017-03-09 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #5 from Jonathan Wakely  ---
(In reply to Benjamin Buch from comment #3)
> Same with decltype instead of noexcept:
> 
> 
> struct test{
> // it only works if e is declared before test()
> using type = decltype(e);
> static const bool e = false;
> };

This code is not valid, GCC is correct to give an error.

[Bug c++/66256] noexcept evaluation done before end of class

2017-03-09 Thread benni.buch at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #4 from Benjamin Buch  ---
Same with decltype instead of noexcept:


struct test{
// it only works if e is declared before test()
using type = decltype(e);
static const bool e = false;
};


$ g++ -std=c++11 gcc-bug.cpp 
gcc-bug.cpp:3:27: error: 'e' was not declared in this scope
 using type = decltype(e);
   ^
gcc-bug.cpp:3:27: error: 'e' was not declared in this scope


$ g++ --version
g++ (GCC) 7.0.1 20170221 (experimental)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/66256] noexcept evaluation done before end of class

2017-03-09 Thread benni.buch at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Benjamin Buch  changed:

   What|Removed |Added

 CC||benni.buch at gmail dot com

--- Comment #3 from Benjamin Buch  ---
Same with decltype instead of noexcept:


struct test{
// it only works if e is declared before test()
using type = decltype(e);
static const bool e = false;
};


$ g++ -std=c++11 gcc-bug.cpp 
gcc-bug.cpp:3:27: error: 'e' was not declared in this scope
 using type = decltype(e);
   ^
gcc-bug.cpp:3:27: error: 'e' was not declared in this scope


$ g++ --version
g++ (GCC) 7.0.1 20170221 (experimental)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/66256] noexcept evaluation done before end of class

2017-02-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

--- Comment #2 from Jonathan Wakely  ---
(In reply to Michael Mehlich from comment #1)
> BTW: The header file could be fixed easily by adding std:: in front of these
> swap occurrences.

No, because that would only consider std::swap and not other functions that can
be found by ADL. That problem is solved for GCC 6 and later by using
__is_nothrow_swappable instead.

[Bug c++/66256] noexcept evaluation done before end of class

2017-02-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-02-14
 Ever confirmed|0   |1

[Bug c++/66256] noexcept evaluation done before end of class

2016-04-23 Thread mmehlich at semanticdesigns dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

Michael Mehlich  changed:

   What|Removed |Added

 CC||mmehlich at semanticdesigns 
dot co
   ||m

--- Comment #1 from Michael Mehlich  ---
I agree, name resolution should consider all declarations in the class,
but apparently gcc does name resolution on the exception specification way too
early.

An example where this causes no error message being created for obviously wrong
code is the swap function in the pair template in the header file
bits/stl_pair.h (for gcc 5.3.0/cygwin), which is declared as
  void
  swap(pair& __p)
  noexcept(noexcept(swap(first, __p.first))
   && noexcept(swap(second, __p.second)))

clang 3.7.1. properly reports an error for the swap in the exception
specification.
BTW: The header file could be fixed easily by adding std:: in front of these
swap occurrences.