[Bug c++/65622] New: No known conversion to initializer_list with default argument in constructor

2015-03-29 Thread david.d.kretzmer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65622

Bug ID: 65622
   Summary: No known conversion to initializer_list with default
argument in constructor
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: david.d.kretzmer at gmail dot com


#include 
struct Foo
{
  Foo(std::initializer_list = {}) {}
};
Foo f{1};


The above code produces the following error (tested in 4.7, 4.8 and 4.9):

error: no matching function for call to 'Foo::Foo()'
note: candidates are:
note: constexpr Foo::Foo(const Foo&)
note: no known conversion for argument 1 from 'int' to 'const Foo&'
note: constexpr Foo::Foo(Foo&&)
note: no known conversion for argument 1 from 'int' to 'Foo&&'
note: Foo::Foo(std::initializer_list)
note: no known conversion for argument 1 from 'int' to
'std::initializer_list'

When I remove the default argument it compiles without errors.
The error only occurs in constructors, normal functions are not affected.


[Bug c++/51553] brace initialization and conversion operators

2014-06-30 Thread david.d.kretzmer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51553

david.d.kretzmer at gmail dot com changed:

   What|Removed |Added

 CC||david.d.kretzmer at gmail dot 
com

--- Comment #4 from david.d.kretzmer at gmail dot com ---
13.3.3.1 p4 [over.best.ics]
[...] or when the initializer
list has exactly one element and a conversion to some class X or reference to
(possibly cv-qualified) X is
considered for the first parameter of a constructor of X, or by 13.3.1.4,
13.3.1.5, or 13.3.1.6 in all cases, only
standard conversion sequences and ellipsis conversion sequences are considered.

If I understand this correctly then the behavior before gcc 4.7 was actually
correct: only standard conversions are considered, conversion functions are
not.


[Bug c++/51553] brace initialization and conversion operators

2014-07-01 Thread david.d.kretzmer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51553

--- Comment #6 from david.d.kretzmer at gmail dot com ---
Exactly. I first thought this is a bug in clang but then I saw this invalid bug
report: http://llvm.org/bugs/show_bug.cgi?id=17376


[Bug c++/61663] New: [DR 976] Deduction for const T& conversion functions

2014-07-01 Thread david.d.kretzmer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61663

Bug ID: 61663
   Summary: [DR 976] Deduction for const T& conversion functions
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: david.d.kretzmer at gmail dot com

GCC 4.9.0 rejects the following code:

struct F 
{
  template
  operator const T&() { static T t; return t; }
};

int main() 
{
  F f;
  int i = f;   // error: cannot convert 'F' to 'int' in initialization
}

As explained in the defects report
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#976) this used to
be invalid but after the corrections in 14.8.2.3 [temp.deduct.conv] paragraphs
1-3 the above code should compile.


[Bug c++/63139] New: Class-scope typedef overwrites typedef of previously defined class

2014-09-02 Thread david.d.kretzmer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63139

Bug ID: 63139
   Summary: Class-scope typedef overwrites typedef of previously
defined class
   Product: gcc
   Version: 4.9.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: david.d.kretzmer at gmail dot com

In GCC 4.8 and 4.9 (4.7 seems to work correctly) a type alias inside a class
seems to overwrite under certain conditions a type alias of the same name in a
previously defined class.
Code to reproduce this bug:


#include 

template
struct type_list {};

template
struct make_type_list
{
using type = type_list;
};

// The bug disappears if you use make_type_list directly.
template
using make_type_list_t = typename make_type_list::type;


struct ContainerEndA {};

template
struct ContainerA
{
using type = make_type_list_t;
};


struct ContainerEndB {};

//template// If you use this line instead
of the next a Internal compiler error is generated.
template
struct ContainerB
{
using type = make_type_list_t;
};


int main()
{
// To see the types in ContainerA<>::type uncomment the following line.
//
//ContainerA<>::type::doesnt_exist; 
//
// GCC error: ‘doesnt_exist’ is not a member of ‘ContainerA<>::type {aka
type_list}’.
// So according to GCC ContainerA<>::type contains ContainerEndB, but it
clearly contains only ContainerEndB!


static_assert(
// It doesn't matter which types you use to instantiate ContainerA and
ContainerB
std::is_same::type, ContainerB::type>::value,
"This assert doesn't fail but it clearly should!"
);
}


I have tried to minimize the code further but any time I remove something the
bug disappears.