[Bug c++/80683] New: Exceptions don't propagate through default member initializer

2017-05-08 Thread majerech.o at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80683

Bug ID: 80683
   Summary: Exceptions don't propagate through default member
initializer
   Product: gcc
   Version: 6.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: majerech.o at gmail dot com
  Target Milestone: ---

Testcase:

#include 
#include 

struct bar {
  bar() {
throw std::runtime_error{"foo"};
  }
};

struct foo {
  bar b{};
};

int
main() try {
  foo f;
} catch (std::runtime_error& e) {
  std::cerr << e.what() << '\n';
}

Running this results in terminate being called:

terminate called after throwing an instance of 'std::runtime_error'
  what():  foo

I would very much expect this code to work – i.e. the exception should be
caught in main. This code does work on Clang 3.9.1 and I couldn't find any
reason in the standard for why the exception shouldn't be allowed to propagate.

Stepping through the code in GDB reveals that after throwing, the call-stack
unwinds all the way to foo's constructor and goes to std::terminate from there,
as if foo::foo() were noexcept.

Changing foo to

struct foo {
  bar b;
};

makes the bug go away. I.e. it only happens when a default member initializer
is used.

I've reproduced this on GCC 6.3.1 and GCC 8.0.0 20170507.

[Bug c++/66139] destructor not called for members of partially constructed anonymous struct/array

2017-05-10 Thread majerech.o at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66139

--- Comment #10 from Ondřej Majerech  ---
That SO answer appears to be plain out wrong. Running your snippet on GCC 6.3.1
and 8.0.0 20170507, the program calls terminate for me, even with the cout <<
"Welcome" line included.

[Bug c++/66139] destructor not called for members of partially constructed anonymous struct/array

2017-05-10 Thread majerech.o at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66139

--- Comment #13 from Ondřej Majerech  ---
(In reply to Xi Ruoyao from comment #12)
> (In reply to Jaak Ristioja from comment #9)
> >   [1]: http://stackoverflow.com/a/43892501/3919155
> 
> I don't think this is the same bug.
> This bug seems happening because GCC created "constexpr B::B(void)", but
> actually
> it throws, so can not be constexpr.

I would also think that to be a different bug, but when I reported that (bug
80683), it got marked as a duplicate of this one. Maybe the duplicate
classification of 80683 should be re-reviewed?

[Bug c++/107953] New: Greater-than operator misparsed inside a lambda expression used as a template argument

2022-12-02 Thread majerech.o at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107953

Bug ID: 107953
   Summary: Greater-than operator misparsed inside a lambda
expression used as a template argument
   Product: gcc
   Version: 12.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: majerech.o at gmail dot com
  Target Milestone: ---

template 
void
f() { }

constexpr auto g = f<[] (int x, int y) { return x > y; }>;

This produces the following diagnostic:
: In lambda function:
:5:50: error: expected ';' before '>' token
5 | constexpr auto g = f<[] (int x, int y) { return x > y; }>;
  |  ^~
  |  ;
:5:51: error: expected primary-expression before '>' token
5 | constexpr auto g = f<[] (int x, int y) { return x > y; }>;
  |   ^
ASM generation compiler returned: 1
: In lambda function:
:5:50: error: expected ';' before '>' token
5 | constexpr auto g = f<[] (int x, int y) { return x > y; }>;
  |  ^~
  |  ;
:5:51: error: expected primary-expression before '>' token
5 | constexpr auto g = f<[] (int x, int y) { return x > y; }>;
  |   ^

Godbolt link to the above: https://godbolt.org/z/KG6d5E6ev

Changing the body to return (x > y); makes the error go away as a workaround.
So I speculate that the greater-than operator is misparsed as the end of the
template argument list.

[Bug c++/107953] Greater-than operator misparsed inside a lambda expression used as a template argument

2022-12-02 Thread majerech.o at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107953

--- Comment #4 from Ondřej Majerech  ---
It seems that the core of PR 57 is that `A