[Bug c++/89745] [[no_unique_address]] has no effect in some cases

2019-03-17 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89745

tower120  changed:

   What|Removed |Added

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

--- Comment #1 from tower120  ---
Sorry, gcc behavior is correct. If empty types should are different - all ok:

struct empty{};
struct empty2{};
using Data = void*;

using P1 = alternative_pair;
using P2 = alternative_pair;

[Bug c++/89745] New: [[no_unique_address]] has no effect in some cases

2019-03-17 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89745

Bug ID: 89745
   Summary: [[no_unique_address]] has no effect in some cases
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

[[no_unique_address]] has no effect in the following case:

https://wandbox.org/permlink/pcMbjWGcdKL3aHJS

template
struct alternative_pair{
[[no_unique_address]] F first;
[[no_unique_address]] S second;
};

int main(){
struct empty{};
using Data = void*;

using P1 = alternative_pair;
using P2 = alternative_pair;


std::cout << sizeof(Data) << std::endl;
std::cout << sizeof(P1) << std::endl;
std::cout << sizeof(P2) << std::endl;

return 0;
}

Output: 8 8 16
Expected: 8 8 8

[Bug c++/86574] ICE on std::prev with ranges::view::transform

2018-07-19 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86574

--- Comment #4 from tower120  ---
Because I don't have gcc 9 locally installed. I saw that ICE on
https://wandbox.org/permlink/bPT0llOGPqouv3CM

Error message says to report - I'm reporting.

[Bug c++/86574] ICE on std::prev with ranges::view::transform

2018-07-19 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86574

--- Comment #2 from tower120  ---
I can't provide a preprocessed source file, but "range/v3/view/transform.hpp"
source is here:

https://github.com/ericniebler/range-v3

[Bug c++/86574] New: ICE on std::prev with ranges::view::transform

2018-07-18 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86574

Bug ID: 86574
   Summary: ICE on std::prev with ranges::view::transform
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

The following code cause ICE on gcc 9. And have malfunction build on all 
previous versions (program compiles, but hangs); clang compiles with error
about bidirectional iterator.

https://wandbox.org/permlink/bPT0llOGPqouv3CM

#include 
#include 
#include 


struct Data{
int x,y;
};

int main() {
std::vector datas = { Data{0,1}, Data{1,2}, Data{1,3} };

const auto xs = datas
| ranges::view::transform([](const Data& data) -> int{
return data.x; });

// no compiler errors / ICEs, but assembled executable - malfunction -
// program hungs, as soon as reach std::prev
//auto j = std::prev(xs.end());  

auto j = std::prev(xs.end(), 1);

std::cout << "Done" << std::endl;

return 0;
}


Error message:

In file included from
/opt/wandbox/range-v3/include/range/v3/view/transform.hpp:26,
 from prog.cc:3:
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp: In instantiation of
'constexpr ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor
>::adaptor_cursor(Args&& ...) [with Args = {__gnu_cxx::__normal_iterator > >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor};
typename
meta::v1::detail::_if_::type::value ...>, std::integer_sequence::type::value) || true ...> >, int>,
std::integral_constant >::type  = 0][inherited from
ranges::v3::compressed_tuple_detail::compressed_tuple_ > >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor >,
std::integer_sequence >]':
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:183:16:   required from
'constexpr ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor
>::adaptor_cursor(Args&& ...) [with Args = {__gnu_cxx::__normal_iterator > >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor};
typename
meta::v1::detail::_if_::type::value ...>, std::integer_sequence::type::value) || true ...> >, int>,
std::integral_constant >::type  = 0][inherited from
ranges::v3::compressed_tuple_detail::compressed_tuple_ > >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor >,
std::integer_sequence >]'
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:405:63:   required from
'static constexpr ranges::v3::adaptor_cursor_t
ranges::v3::view_adaptor::begin_cursor_(D&) [with D =
const
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >; Derived =
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >; BaseRng =
ranges::v3::iterator_range<__gnu_cxx::__normal_iterator >, __gnu_cxx::__normal_iterator > >;
ranges::v3::cardinality Cardinality = (ranges::v3::cardinality)-1;
ranges::v3::adaptor_cursor_t =
ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator >,
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor >;
typename std::decay(), 42))>::type =
ranges::v3::iter_transform_view >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >::adaptor;
typename std::decay(),
42))>::type>().begin(declval()))>::type =
__gnu_cxx::__normal_iterator >]'
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:423:13:   required by
substitution of 'template > >, __gnu_cxx::__normal_iterator > > >,
ranges::v3::indirected > > >::type() &&
ranges::v3::concepts::models > >, __gnu_cxx::__normal_iterator > > > >())), void>::type*  >
constexpr decltype
(ranges::v3::view_adaptor >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >,
ranges::v3::iterator_range<__gnu_cxx::__normal_iterator >, __gnu_cxx::__normal_iterator > >,
(ranges::v3::cardinality)-1>::begin_cursor_(declval()))
ranges::v3::view_adaptor >, __gnu_cxx::__normal_iterator > >,
ranges::v3::indirected > >,
ranges::v3::iterator_range<__gnu_cxx::__normal_iterator >

[Bug libstdc++/86507] std::filesystem not work on Windows

2018-07-13 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86507

--- Comment #4 from tower120  ---
> Are you sure about that? You might be able to include the header, but nothing 
> else works.

"Everything" that I use, which is:
 * std::experimental::filesystem::path (construction, c_str, comparison)
 * std::experimental::filesystem::file_size

This work in mingw-w64 gcc 7.1 with "stdc++fs".

[Bug libstdc++/86507] std::filesystem not work on Windows

2018-07-12 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86507

--- Comment #1 from tower120  ---
Created attachment 44388
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44388=edit
compilation error message

[Bug libstdc++/86507] New: std::filesystem not work on Windows

2018-07-12 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86507

Bug ID: 86507
   Summary: std::filesystem not work on Windows
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

Just including "filesystem" header on gcc 8.1 under windows (mingw-w64) cause
compilation error. See attached file. All 7.x with "experimental/filesystem"
worked fine.

#include 
int main() {
return 0;
}

Problem code here:
bits/fs_path.h

#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
  if (__p.is_absolute()
  || (__p.has_root_name() && __p.root_name() != root_name()))
operator=(__p);


error: no match for 'operator!=' (operand types are
'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')

[Bug c++/86495] New: false no return statement warning in "if constexpr" branch

2018-07-11 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86495

Bug ID: 86495
   Summary: false no return statement warning in "if constexpr"
branch
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

The following code produce false "no return statement" warning in gcc 8.1.
Everything fine on 7.x

Live: https://godbolt.org/g/dCuFci

#include 
#include 

template
class variant_w_base{
Base* m_base;
Variant m_variant;

void update_base(){
m_base = std::visit([](auto&& arg) -> Base* {
using Arg = std::decay_t;
// ERRONEOUS WARNING HERE.
if constexpr (std::is_same_v){
return nullptr;
} else {
return static_cast();
}
}, m_variant);
}

public:
variant_w_base(){
update_base();
}
};


int main() {
struct Base{};
struct Data : Base{};
variant_w_base> v;

return 0;
}

[Bug c++/82619] C++17 std::apply treated as in global namespace under certain circumstances

2017-10-19 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82619

tower120  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from tower120  ---
Sorry, this is ADL indeed.

I just noticed, that I tested in other compilers with -std=C++14 flag. That's
why that worked in all other compilers and pre gcc7.


Now, being aware of ADL, I am able to make the shortest version of "bug":

#include 

namespace ns {
template
static constexpr decltype(auto) apply_impl(F &, Tuple &,
std::index_sequence) {
return f(std::get(std::forward(t))...);
}

template
static constexpr decltype(auto) apply(F &, Tuple &) {
return apply_impl(std::forward(f), std::forward(t),
 
std::make_index_sequence::value>{});
}

template
static void foreach_tuple(Closure &, Tuple &) {
//ns::
apply([&](auto &&... args) {}, tuple);
}
}


int main() {
std::tuple t = {1,2,3};
ns::foreach_tuple([](auto i){}, t);
return 0;
}

[Bug c++/82619] C++17 std::apply treated as in global namespace under certain circumstances

2017-10-19 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82619

--- Comment #2 from tower120  ---
> If a `std::tuple` is passed in as `tuple`, isn't `std::apply` found by ADL?

Maybe, I don't understand how and when ADL work :(

Visual Studio / clang compiler said nothing about it, so I thought ...

Are you sure, this is the case?

[Bug c++/82619] New: C++17 std::apply treated as in global namespace under certain circumstances

2017-10-19 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82619

Bug ID: 82619
   Summary: C++17 std::apply treated as in global namespace under
certain circumstances
   Product: gcc
   Version: 7.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

Created attachment 42403
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42403=edit
cmake project. Look at test/main.cpp

Under certain circumstances C++17's std::apply treated as if it is in global
namespace.

See attached cmake project. Specially src/reactive/oberver.h. Project is fail
to compile, with function is ambiguous error.

uncommenting /src/reactive/oberver.h line 49 makes it compilable.

[Bug c++/67247] ICE on std::forward args&& inside nested lambda function

2016-04-25 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67247

tower120  changed:

   What|Removed |Added

  Known to work||6.0

--- Comment #4 from tower120  ---
Reduced case [Forwarding captured variadic arguments inside lambda] :
https://godbolt.org/g/D7lXEA

template
int g(T... t)
{
return 0;
}

template
void f(Args&&... args)
{
auto lm = [&](auto&&..._args) { 
auto f = [&]{g(std::forward(_args)...);};
  //auto f = [&]{g(_args...);}; /* THIS ONE OK */
return f(); 
};
lm(args...);
}

int main()
{
f(2, 5, 7);
}

Error "_args was not declared" on 4.9.x
ICE on 5.x
Ok on 6.x

[Bug c++/70343] internal compiler error: in tsubst_copy, wrong code with lambda in template fn

2016-03-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70343

--- Comment #2 from tower120  ---
The workaround for all versions is use lambda that doesn't CAPTURE this, e.g.

http://coliru.stacked-crooked.com/a/e223ddb156d817c1


struct Empty{};

template 
struct Data{
int properties_parcel4[10];

Empty j = [](auto& self){
 self.properties_parcel4[0] = 10;
return Empty(); 
}(*this);
};

int main () {
Data k;

  return 0;
}


P.S. This maybe somehow related to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636 - problem workarounds are
same.

[Bug c++/70343] New: internal compiler error: in tsubst_copy

2016-03-21 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70343

Bug ID: 70343
   Summary: internal compiler error: in tsubst_copy
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

The following code cause ICE in 4.9.2, in 5.3 cause Segmentation fault. Works
ok in non-templated version. Woks ok with clang and VS.

http://coliru.stacked-crooked.com/a/82069f4880198da6


#include  // std::cout
#include   // ::operator new
#include 
#include 
#include 

using namespace std;

struct Empty{};


template   /* <-- Because of Template */
struct Data{
int x;
float y;

int properties_parcel4[10];

Empty j = [&](){
int i = 10;
properties_parcel4[0] = i;
return Empty(); 
}();
};

int main () {
Data k;

  return 0;
}

[Bug c++/67247] New: ICE on std::forward args inside nested lambda function

2015-08-17 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67247

Bug ID: 67247
   Summary: ICE on std::forward args inside nested lambda
function
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

Code as is:
http://coliru.stacked-crooked.com/a/903e76d5446bfeb2

#include iostream
#include tuple

#include utility

template class F1, class F2
decltype(auto) operator  (F1 f1, F2 f2){
using namespace std;
return f2(forwardF1(f1));
}

template class F1, class F2
decltype(auto) operator  (F1 f1, F2 f2){
using namespace std;
return f1(forwardF2(f2));
}


// curry 2 args pack (temporary)
#define f(...) \
[](auto ...args1){return  \
[](auto ...args2){return __VA_ARGS__
(std::forwarddecltype(args1)(args1)..., args2...);} ;  /* -- ICE HERE!*/ \ 
}


using namespace std;

auto sum(int a, int b){
return a+b;
}

auto divide(int a, int b){
return a/b;
}


int main() {
float a = 10;
float b = 20;

auto part1 =  f(divide)  5;  // just for test purpose

auto res = sum(a,b)  f(divide)  5;

auto res_ctrl = divide(sum(a,b), 5.0);


cout  res :  res  endl;
cout  ctrl:  res_ctrl  endl;

return 0;
}



C:\Dropbox\C++\exp_chained_call\simple_chain.h:22:49: internal compiler error:
Segmentation fault
 [](auto ...args2){return __VA_ARGS__
(std::forwarddecltype(args1)(args1)..., args2...);} ; \

Without std::forwarddecltype(args1) it is ok.
With [](auto ...args2){return __VA_ARGS__ (args1...,
std::forwarddecltype(args2)(args2)...);} ; ok also.


P.S. I just realize, that args1 is probably stored as , not  inside
lambda... But ICE is ICE.


[Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal

2015-08-03 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67100

--- Comment #1 from tower120 tower120 at gmail dot com ---
if change 

#define dispatch_forward_fn(fn_name, prefix) \
templateclass Caller, class Me \
struct DispatcherCaller, tstring(go_up), Me{ /* Problem here tstring(go_up)
*/\
templateclass ...Args, class ...ArgsRef \
inline decltype(auto) operator() (ArgsRef... args) {\
return 0; \
} \
};



with:


#define dispatch_forward_fn(fn_name, prefix) \
templateclass Caller, class Me \
using H_##fn_name = tstring(fn_name); \
struct DispatcherCaller, H_##fn_name, Me{ \
templateclass ...Args, class ...ArgsRef \
inline decltype(auto) operator() (ArgsRef... args) {\
return 0; \
} \
};

ICE does not occurs.


[Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal

2015-08-03 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67100

Bug ID: 67100
   Summary: ICE(in type_dependent_expression_p) on macro function
+ user defined literal
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com
  Target Milestone: ---

Live errors : #http://goo.gl/UlaJI7

The following code:
//-

#include typeinfo
#include tuple

#define CAT1(A, B) A ## B
#define CAT(A, B) CAT1(A, B)

#define TOKEN_TO_STRING(TOK) # TOK
#define STRINGIZE_TOKEN(TOK) TOKEN_TO_STRING(TOK)


template char... chars
using _tstring = std::integer_sequencechar, chars...;

template typename T, T... chars
constexpr _tstringchars... operator_tstr() { return { }; }

#define tstring(STR) decltype( CAT( TOKEN_TO_STRING(STR), _tstr) )



#define dispatch_forward_fn(fn_name, prefix) \
templateclass Caller, class Me \
struct DispatcherCaller, tstring(go_up), Me{ \
templateclass ...Args, class ...ArgsRef \
inline decltype(auto) operator() (ArgsRef... args) {\
return 0; \
} \
};

#define dispatch_list_prefix \
templateclass Caller, class Fn_name, class Me \
struct Dispatcher; \
dispatch_forward_fn(go_up, _d)


dispatch_list_prefix

int main(){
Dispatchervoid, tstring(go_up), void()();
return 0;
}


//-

Produces following error at gcc 4.9.2 (any flags):

/tmp/gcc-explorer-compiler11573-68-zk0erd/example.cpp: In instantiation of
'struct Dispatchervoid, std::integer_sequencechar, 'g', 'o', '_', 'u', 'p',
void':
40 : required from here
37 : internal compiler error: in type_dependent_expression_p, at cp/pt.c:21020


[Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal

2015-08-03 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67100

--- Comment #3 from tower120 tower120 at gmail dot com ---
Forgot to say - it's ok with gcc 5.1


[Bug c++/62222] 'tuple_element_t' was not declared in this scope

2014-08-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

--- Comment #3 from tower120 tower120 at gmail dot com ---
Oh I see.

Well, what gcc version is that, then? http://patchwork.ozlabs.org/patch/339121/


[Bug c++/62223] New: error: there are no arguments to ‘static_asssert’ that depend on a template parameter, so a declaration of ‘static_asssert’ must be available

2014-08-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62223

Bug ID: 62223
   Summary: error: there are no arguments to ‘static_asssert’ that
depend on a template parameter, so a declaration of
‘static_asssert’ must be available
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

May be not a bug... But, why error occurs in the following code?

#include tuple
#include utility
using namespace std;

templateclass ..._Attrs
class VertexBuffer
{
static constexpr const bool ownIndices = sizeof...(_Attrs) == 0;

void test(){
static_asssert(ownIndices, Link to owned indices!!);
}
}


int main(){}

error: there are no arguments to 'static_asssert' that depend on a template
parameter, so a declaration of 'static_asssert' must be available
[-fpermissive]
 static_asssert(ownIndices, Link to owned indices!!);
 ^

Doesn't ownIndices template-dependent value?

Compiled with MinGW 4.9

[Bug c++/62223] error: there are no arguments to ‘static_asssert’ that depend on a template parameter, so a declaration of ‘static_asssert’ must be available

2014-08-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62223

--- Comment #2 from tower120 tower120 at gmail dot com ---
No, I compile it with -std=c++1y

Here, live example http://ideone.com/KsGrnH (though that is gcc-4.8.1)


[Bug c++/62223] error: there are no arguments to ‘static_asssert’ that depend on a template parameter, so a declaration of ‘static_asssert’ must be available

2014-08-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62223

--- Comment #4 from tower120 tower120 at gmail dot com ---
Typo indeed.
I'm so sorry.


[Bug c++/62223] error: there are no arguments to ‘static_asssert’ that depend on a template parameter, so a declaration of ‘static_asssert’ must be available

2014-08-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62223

--- Comment #6 from tower120 tower120 at gmail dot com ---
Well, classical static_asssert is not a function/variable/etc would be enough
for me.

Because there are no arguments to 'static_asssert' that depend on a template
parameter means that there IS such a function, but it does not accept current
parameters set (IMHO).


[Bug c++/62222] New: 'tuple_element_t' was not declared in this scope

2014-08-21 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Bug ID: 6
   Summary: 'tuple_element_t' was not declared in this scope
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

In the following code (http://coliru.stacked-crooked.com/a/f78031af320b07f0)

#include iostream
#include tuple
#include stdlib.h 
#include array

using namespace std;

int main(){

using T  = tupleint, float, char;
using el = tuple_element_t0, T;
}


main.cpp: In function 'int main()':
main.cpp:12:16: error: 'tuple_element_t' does not name a type
 using el = tuple_element_t0, T
^
Compiled with gcc 4.9 MinGW Windows.
g++ -std=c++1y  -O3 -Winline -Wextra -pthread -pedantic-errors main.cpp -lm  
./a.out


[Bug c++/62149] New: ICE in tsubst_copy, at cp/pt.c:12646 with constexpr and tuple_size

2014-08-14 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62149

Bug ID: 62149
   Summary: ICE in tsubst_copy, at cp/pt.c:12646  with constexpr
and tuple_size
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

In the following code:

#include iostream
#include string
#include vector
#include tuple

using namespace std;

templateclass ..._Attrs
struct Test{
using Attrs22 = tuple _Attrs... ;
Attrs22 attrs22;

void setup(){
int constexpr size2 = tuple_sizeAttrs22::value;
int idsa[size2];

//int idsa[tuple_sizeAttrs22::value];   // this works ok!

auto fn =  [](auto attr){
   idsa[0];
};
fn(11);
}
};


int main()
{
Testint, int, int t;
t.setup();  
}


Compiled with:
g++ -std=c++1y  -O3 -Winline -Wextra -pthread -pedantic-errors main.cpp -lm  
./a.out

I have the following error:
internal compiler error: in tsubst_copy, at cp/pt.c:12646
idsa[0];
^
libbacktrace could not find executable to open


---
P.S. If not use constexpr, all works fine.


[Bug c++/61892] RVO not occurs with constructor with universal reference arguments

2014-07-24 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61892

--- Comment #2 from tower120 tower120 at gmail dot com ---
Well ok, but what about this?

http://coliru.stacked-crooked.com/a/e3ce8882c68dbef2

Why it copy with wrong number of argument?


[Bug c++/61892] RVO not occurs with constructor with universal reference arguments

2014-07-24 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61892

--- Comment #3 from tower120 tower120 at gmail dot com ---
But wait, we talk about move constructor. But this is a template class.
Template class can not have move constructor at all.


[Bug c++/61892] New: RVO not occurs with constructor with universal reference arguments

2014-07-23 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61892

Bug ID: 61892
   Summary: RVO not occurs with constructor with universal
reference arguments
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

I'm not sure that this is bug. But this is strange behavior, if you ask me.

LIVE: http://coliru.stacked-crooked.com/a/d11d50f611ed0cee

In the following code:

#include iostream

templateclass ...ArgsIn
struct C {

  templateclass ...Args
  C(Args ... args) {std::cout  Ctr\n;}// elision occurs without


  ~C(){std::cout  Dstr\n;}
  //C(C) { std::cout  A move was made.\n; }   // with this and universal
references in ctr, rvo occurs
};

templateclass ...Args 
auto f(Args ... args) {
  int i = 1;
  std::cout  call std::endl;
  return C(i, i, i);
}

int main() {
  std::cout  Hello World!\n;
  auto obj = f();
}

OUTPUT:

g++ -std=c++1y  -O3 -Winline -Wextra -pthread -pedantic-errors main.cpp -lm  
./a.out
Hello World!
call 
Ctr
Ctr
Dstr
Ctr
Dstr
Dstr

=

1) If I have constructor with universal references I need to have ANY move
constructor, so rvo happened. 
2) Moreover, when rvo not happens, it construct object with a wrong number of
arguments:
http://coliru.stacked-crooked.com/a/e3ce8882c68dbef2

=


P.S.
http://stackoverflow.com/questions/24925137/c-universal-reference-in-constructor-and-return-value-optimization-rvo/24925451#comment38729738_24925137
someone claims that with gcc 4.8.3 this problem not exists. I don't have that
compiler at hand, so I can't check that.


[Bug c++/61636] generic lambda cannot call member function without object

2014-07-06 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636

--- Comment #7 from tower120 tower120 at gmail dot com ---
I'm not sure what you mean, about adding this-. But this case is not working
:
http://coliru.stacked-crooked.com/a/d69de477f9a746cb

But to be true, it not work with clang either.


[Bug c++/61636] New: generic lambda cannot call member function without object

2014-06-28 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636

Bug ID: 61636
   Summary: generic lambda  cannot call member function without
object
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

In the following code:
Live http://coliru.stacked-crooked.com/a/b22bb3c9cd603bc7



#include type_traits
#include iostream

templateclass datatype, class FN1, class FN2
auto if_else(std::true_type,datatype data, FN1 fn1, FN2 ) 
{return fn1(std::forwarddatatype(data));}

templateclass datatype, class FN1, class FN2
auto if_else(std::false_type,datatype data, FN1 , FN2 fn2)
{return fn2(std::forwarddatatype(data));}


// -



struct A{
int id= 4;
};

struct B : A{
int h = 900;
};

class Test{

templateclass Ba
int fn1(Ba a){
std::cout  fn1   a.h;
return a.h;
};

templateclass A
int fn2(A a){
std::cout  fn2   a.id;
a.id = 9;
return a.id;
};



public:
templatebool do_it
void go(){
std::integral_constantbool,do_it do_first;

using datatype = typename std::conditionaldo_it,B,A::type;
datatype data;
std::cout  std::is_samedecltype(data), A::value;

std::cout  if_else(do_first, data,
[](auto /*B*/ data){   // comment auto to get rid
of error

std::cout  std::endl;
std::cout  std::is_samedecltype(data), B::value;
std::cout  std::endl;

return fn1(/*static_castB*/(data)); // static cast
not work with gcc
},
[](A data){ return fn2(data); }
);
}
};

int main(){
Test().template gofalse();
Test().template gotrue();
return 0;
}

I got the following error:

main.cpp:58:61: error: cannot call member function 'int Test::fn1(Ba) [with Ba
= B]' without object


If change auto with B - works fine. And it compiles and work as is with clang.

P.S. Maybe somehow related to this
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49554


[Bug c++/61636] generic lambda cannot call member function without object

2014-06-28 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636

--- Comment #1 from tower120 tower120 at gmail dot com ---
Furthermore, if not pass data as a lambda function param, but capture it from
current scope, it deduces type wrong.

http://coliru.stacked-crooked.com/a/ae022b9d25d93490
Uncomment static_cast to make it work.

But may be this is unrelated to described above issue.


[Bug c++/61636] generic lambda cannot call member function without object

2014-06-28 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636

--- Comment #3 from tower120 tower120 at gmail dot com ---
I found that as only I pass *this as parameter and then call functions from it,
it works ok. But it have to be auto:

/// This work
std::cout  if_else(do_first,
*this,
[](auto self){ return self.fn1(data); },
[](auto self){ return self.fn2(data); }
)  '\n';


/// This not
std::cout  if_else(do_first,
*this,
[](Test self){ return self.fn1(data); },
[](Test self){ return self.fn2(data); }
)  '\n';

http://coliru.stacked-crooked.com/a/272a5e0b8089a5c4

And what even more strange, it work if only one lambda is auto:

std::cout  if_else(do_first,
*this,
[](auto self){ return self.fn1(data); },
[](Test self){ return self.fn2(data); }  // ???
)  '\n';

http://coliru.stacked-crooked.com/a/ed45a402a6c11d63


[Bug c++/61290] New: init templated member variable with constructor fails

2014-05-22 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61290

Bug ID: 61290
   Summary: init templated member variable with constructor fails
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

This one related to this:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51666
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52595

Consider the following code:
struct S{
//typedef S ThisT;

templateclass IdsT, class DataT
struct CallbackPack{
CallbackPack(IdsT selfIds):
selfIds(selfIds){}

const IdsT  selfIds;
};

const  CallbackPackS, S callbackPack123 = CallbackPackS, S((*this));
};

int main()
{
return 0;
}

http://coliru.stacked-crooked.com/a/ea9ed4482306ce17

Which produce the following errors:
main.cpp:16:65: error: expected ';' at end of member declaration
 const  CallbackPackS, S callbackPack123 = CallbackPackS, S((*this));
 ^
main.cpp:16:66: error: expected unqualified-id before '' token
 const  CallbackPackS, S callbackPack123 = CallbackPackS, S((*this));
  ^
main.cpp:16:65: warning: non-static const member 'const S::CallbackPackS, S
S::S' in class without a constructor [-Wuninitialized]
 const  CallbackPackS, S callbackPack123 = CallbackPackS, S((*this));
 ^
main.cpp:16:62: error: wrong number of template arguments (1, should be 2)
 const  CallbackPackS, S callbackPack123 = CallbackPackS, S((*this));
  ^
main.cpp:9:12: error: provided for 'templateclass IdsT, class DataT struct
S::CallbackPack'
 struct CallbackPack{


The workarounds for this:

const  CallbackPackS, S callbackPack123 = (CallbackPackS, S((*this)));

http://coliru.stacked-crooked.com/a/f8658477b7379e8e

and

const  CallbackPackS, S callbackPack123{*this};

http://coliru.stacked-crooked.com/a/3e0c71de722801bb


[Bug c++/61213] New: std::forward_as_tuple and std::tupleT and any rvalue loose data

2014-05-17 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61213

Bug ID: 61213
   Summary: std::forward_as_tuple and std::tupleT and any
rvalue loose data
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

std::forward_as_tuple elements loose data on -O2.
Works fine with -O0


Consider the following code:
http://coliru.stacked-crooked.com/a/67499e052283bd5a

#include iostream
#include tuple

class Widget {
public:
  Widget(int h) : h(h){}
  int h;
};

templatetypename T
struct RvalueTest{
RvalueTest(T value) : value( std::forwardT(value) ){}
T value;
};

int main() {
auto t = std::forward_as_tuple(Widget(12));
//auto t = std::tupleWidget(Widget(12));  // this not work also
std::cout  std::get0(t).h;// -- some random value here

/// This one not work, either:
/*RvalueTestWidget r(Widget(12));
std::cout  r.value.h;*/
}


Code from above works fine with clang compiler.
I suspect that rvalue object life time is wrong in -O2 mode.


[Bug c++/61213] [4.7/4.8/4.9/4.10 Regression] std::forward_as_tuple and std::tupleT and any rvalue loose data

2014-05-17 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61213

--- Comment #2 from tower120 tower120 at gmail dot com ---
(In reply to Jonathan Wakely from comment #1)
 Using -fno-indirect-inlining gives the correct result

I not see this with
-std=c++11 -O2 -fno-indirect-inlining -Wall -pedantic -pthread

http://coliru.stacked-crooked.com/a/e7c9408daef01448


[Bug c++/61178] New: expansion pattern '#'nontype_argument_pack' not supported by dump_expr#

2014-05-13 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61178

Bug ID: 61178
   Summary: expansion pattern '#'nontype_argument_pack' not
supported by dump_expr#
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tower120 at gmail dot com

I got strange error:

expansion pattern '#'nontype_argument_pack' not supported by dump_expr#

With the following code:
http://coliru.stacked-crooked.com/a/bbacd7e9bec149f0

--
#include iostream
#include utility
#include type_traits
#include typeinfo

using namespace std;


struct Void{
static constexpr int size = 0;
};

templatetypename T0, typename T1
class Variadic{
private:
typedef VariadicT0, T1 thisT;

public:
/** Do not use this constructor */
Variadic(T0 el0, T1 el1): value(el0), next(el1) {}

// avoiding decltype
typedef T0 valueT;
T0 value;

typedef T1 nextT;
T1 next; // may be next pair

/**
 * Chainable method
 */
templatetypename ValueT
/*constexpr*/ inline VariadicValueT, thisT add(ValueT value){
return VariadicValueT, thisT(value, (*this) );
}

};

templatetypename T
static inline VariadicT, Void make_variadic(T value){
return VariadicT, Void(value, Void());
}




/// ERROR IS HERE!
templatetypename Arg0, typename... Args
static inline auto make_variadic(Arg0 value0, Args... values) - decltype(
fill(make_variadicArg0(value0), values...) ) {
return fill(make_variadicArg0(value0), values...);
}


///  THIS ONE BELOW, WORKS FINE
/*
templatetypename Arg0, typename... Args
static inline auto make_variadic(Arg0 value0, Args... values) -
decltype(fill(VariadicArg0, Void(value0, Void()), values...)) {
return fill(VariadicArg0, Void(value0, Void()), values...);
}*/


templatetypename T, typename Arg0, typename... Args
static inline auto fill(T self, Arg0 value, Args... values) -
decltype(fill(self.add(value), values...)){
return fill(self.add(value), values...);
}

templatetypename T, typename Arg0
static inline auto fill(T self, Arg0 value) - decltype(self.add(value)){
return self.add(value);
}



int main()
{
auto list = make_variadic(1, 2, 3);
}


--
Command line from coliru:
g++-4.8 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors
main.cpp -lm   ./a.out


Clang compile this without errors.


If I replace make_variadic call (see code above) with function body, it works
ok.


[Bug c++/61178] expansion pattern '#'nontype_argument_pack' not supported by dump_expr#

2014-05-13 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61178

tower120 tower120 at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from tower120 tower120 at gmail dot com ---
This may be related to this
http://open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1433


[Bug c++/61178] expansion pattern '#'nontype_argument_pack' not supported by dump_expr#

2014-05-13 Thread tower120 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61178

tower120 tower120 at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|FIXED   |---

--- Comment #2 from tower120 tower120 at gmail dot com ---
resolved by mistake.