[Bug c++/59978] New: C++11 Non-Type-Template-Parameter Pack Expansion not working according to standard

2014-01-29 Thread aemseemann at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59978

Bug ID: 59978
   Summary: C++11 Non-Type-Template-Parameter Pack Expansion not
working according to standard
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aemseemann at gmail dot com

Created attachment 31976
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31976&action=edit
minimal-example source file from the description

In the code below "Ints..." should expand to "1, 2" and therefore correctly
match the signature for "testFunc", but g++ 4.8.2 complains about
"too few arguments to function ‘void testFunc(int, int)’"

static void testFunc(int i1, int i2) {
(void)i1;
(void)i2;
}

template  void wrapper() {
testFunc(Ints...);
}

int main(int, char *[]) {
wrapper<1, 2>();
return 0;
}

Command line: g++ -std=c++11 -Wall -Wextra non-type-template-parameter-pack.cpp

Tested with g++ 4.8.2 on ArchLinux (i686):
g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.8.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /build/gcc/src/gcc-4.8-20131219/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-cloog-version-check --enable-lto
--enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu
--disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.2 20131219 (prerelease) (GCC) 

GCC from Git-master from 2014/01/28 produces the same error message.

The code compiles fine on clang (3.3 and 3.4)

[Bug libstdc++/109947] New: std::expected monadic operations do not support move-only error types yet

2023-05-23 Thread aemseemann at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109947

Bug ID: 109947
   Summary: std::expected monadic operations do not support
move-only error types yet
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aemseemann at gmail dot com
  Target Milestone: ---

GCC13 introduce monadic operations for `std::expected`, including r-value
ref-qualified overloads, which suggests that it should be possible to use an
expected with a move-only value or error type.

However, the following [example](https://godbolt.org/z/aoWeaqoGz) does not
compile due to an attempt to use unique_ptr's the deleted copy constructor:

```cpp
#include 
#include 

int main() 
{   
using expected = std::expected>;

expected e{42};
std::move(e).and_then([](auto&&) -> expected {
return 0;
});

return 0;
}

```

The issue seems to be the use of `std::move(value())` in the &&-qualified
overloads of the monadic operations (e.g.
[here](https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/expected#L880)
which selects the `value() &` overload that in turn attempts a copy of the
error type in the  [exception
path](https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/expected#L740).

When replacing the value access with `std::move(*this).value()` the example
compiles successfully.

[Bug libstdc++/109947] std::expected monadic operations do not support move-only error types yet

2023-05-24 Thread aemseemann at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109947

--- Comment #3 from Martin Seemann  ---
Thanks for pointing me to the LWG issue. It makes sense that the error type
must be copyable for the `value()` overloads due to potentially throwing a
`bad_expected_access` with the embedded error embedded.

However, the monadic operations will never throw this exception.
Consequently, the standard draft for the monadic operations
(https://eel.is/c++draft/expected.object.monadic) does not contain any
"Throws:" clause nor is copyability of the error type included in the
"Constraints:" clause.

So it comes down to how to interpret the "Effects:" clause: Does "Equivalent to
" mean  that all restrictions of
`value()` apply transitively or is it merely an implementation hint?

(Strangely enough, in the "Effects:" clause of `value_or()&&` the expression
`std::move(**this)` is used  instead of `std::move(value())`. Maybe this is an
oversight/inconsistency of the standard.)

[Bug libstdc++/109947] std::expected monadic operations do not support move-only error types yet

2023-05-24 Thread aemseemann at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109947

Martin Seemann  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #5 from Martin Seemann  ---
Thanks for the clarification! Now I am convinced that it is not a bug in
libstdc++ (although I still doubt that the side-effects were intended when the
committee formulated the "Effects" for monadic operations, but that's not
relevant here).

Marking as resolved and sorry for the noise.

[Bug libstdc++/109947] std::expected monadic operations do not support move-only error types yet

2023-06-06 Thread aemseemann at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109947

--- Comment #9 from Martin Seemann  ---
That's great news, looking forward to the next point release.
Thank you very much for taking this to the committee and getting the process in
motion so quickly!