[Bug c++/66670] "template argument deduction/substitution failed" with function pointers and multiple parameter packs

2019-11-02 Thread schlaffi at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670

schlaffi at users dot sourceforge.net changed:

   What|Removed |Added

 CC||schlaffi at users dot 
sourceforge.
   ||net

--- Comment #3 from schlaffi at users dot sourceforge.net ---
This still affects g++ 9.2.1.

clang fixed this between 6.0.0 and 7.0.0, icc 13 and msvc 19 also work.
This has nothing to do with class functions:

static void foo( int, int ) { }

template 
void bar1( void ( * )( int, T... ) ) { }

template 
void bar2( void ( * )( T..., int ) ) { }

int main() {
  bar1( foo );
  bar2( foo );
}

Because we have twice "int" in foo, the error message is slightly different:

arg_deduct.cc: In function ‘int main()’:
arg_deduct.cc:11:18: error: no matching function for call to ‘bar2(void
(&)(int, int))’
   11 |   bar2( foo );
  |  ^
arg_deduct.cc:7:6: note: candidate: ‘template void bar2(void (*)(T
..., int))’
7 | void bar2( void ( * )( T..., int ) ) { }
  |  ^~~~
arg_deduct.cc:7:6: note:   template argument deduction/substitution failed:
arg_deduct.cc:11:18: note:   candidate expects 1 argument, 2 provided
   11 |   bar2( foo );
  |  ^

The analogous construction with classes works like charm:

template 
struct Foo {};
static Foo foo;

template  typename C>
void bar1( C ) {}

template  typename C>
void bar2( C ) {}

int main() {
  bar1( foo );
  bar2( foo );
}

[Bug c++/84045] New: ICE when is_nothrow_default_constructible is used before #include

2018-01-25 Thread schlaffi at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84045

Bug ID: 84045
   Summary: ICE when is_nothrow_default_constructible is used
before #include
   Product: gcc
   Version: 7.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: schlaffi at users dot sourceforge.net
  Target Milestone: ---

The following valid code

#include 

template 
struct dummy{
 typedef std::is_nothrow_default_constructible dc;
 void fu()noexcept(dc::value){}
};

#include 

int main(){
 std::set bar;
 return 0;
}

causes the ICE:

In file included from /usr/include/c++/7/set:60:0,
 from ice.cc:9:
/usr/include/c++/7/bits/stl_tree.h: In instantiation of
‘std::_Rb_tree_key_compare<_Key_compare>::_Rb_tree_key_compare() [with
_Key_compare = std::less]’:
ice.cc:12:16:   required from here
/usr/include/c++/7/bits/stl_tree.h:146:7: internal compiler error: Segmentation
fault
   _Rb_tree_key_compare()

The following changes make the code compile without error:

- include  before struct dummy
- force dc::value to be bool (e.g. not not dc::value or bool(dc::value))
- expand the typedef in dc::value
- have only one template parameter

But, it took me quite a while to find what line causes the error.

My gcc is

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)

[Bug libstdc++/57674] wrong distribution for std::binomial_distribution::operator()(g,param)

2013-06-22 Thread schlaffi at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57674

--- Comment #5 from schlaffi at users dot sourceforge.net ---
yes, it's fixed :) I tested various examples (also large param.t).


[Bug c++/57679] New: c++11: ICE on template type alias to enum

2013-06-22 Thread schlaffi at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57679

Bug ID: 57679
   Summary: c++11: ICE on template type alias to enum
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: schlaffi at users dot sourceforge.net

struct B{ enum C{}; };
template  using A=typename T::C;
A d;

triggers an ICE:

y.cc:3:4: internal compiler error: Segmentation fault

I would expect that this is even valid code? The "struct B" embedding is not
needed --- I just thought that "using A=T" look very wired. llvm compiles
without complains.


[Bug libstdc++/57674] wrong distribution for std::binomial_distribution::operator()(g,param)

2013-06-22 Thread schlaffi at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57674

--- Comment #2 from schlaffi at users dot sourceforge.net ---
Created attachment 30338
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30338&action=edit
corrected version of the example file

sorry, forgot one line, the output should be

distribution 1: p = 0.8, f = 0.798828
distribution 2: p = 0.3, f = 0.206055

(bad) vs.

distribution 1: p = 0.8, f = 0.793945
distribution 2: p = 0.3, f = 0.308594

(good)


[Bug libstdc++/57674] wrong distribution for std::binomial_distribution::operator()(g,param)

2013-06-22 Thread schlaffi at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57674

schlaffi at users dot sourceforge.net changed:

   What|Removed |Added

Version|4.7.2   |lno

--- Comment #1 from schlaffi at users dot sourceforge.net ---
i mean v4.7.2 :o


[Bug libstdc++/57674] New: wrong distribution for std::binomial_distribution::operator()(g,param)

2013-06-22 Thread schlaffi at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57674

Bug ID: 57674
   Summary: wrong distribution for
std::binomial_distribution::operator()(g,param)
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: schlaffi at users dot sourceforge.net

Created attachment 30337
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30337&action=edit
example where bindist(gen,param) fails

std::binomial_distribution::operator()(g,param) produces an invalid statistic.
It uses the old probability p_old if param.p<.5 and otherwise 1-p_old. Looks
like a typo.

That is, dist(gen,para2); gives 

distribution 1: p = 0.8, f = 0.798828
distribution 2: p = 0.3, f = 0.206055

while dist.param(para2);dist(gen); gives

distribution 1: p = 0.8, f = 0.324219
distribution 2: p = 0.3, f = 0.295898

I briefly checked the SVN, there does not seem to be a change since v2.7.8.