[Bug c++/21895] New: [wrong-code] template class member function with array typedef arguement behaves erroneously

2005-06-02 Thread leventyilmaz at gmail dot com
Here is a sample code that generates the problem (tried to reduce it as much as
possible):

#include
template
class Bar 
{
public:
  void foo(T a) { std::cout << a << std::endl; }
};

int main()
{
  typedef int arr[3];
  arr sz={0,1,2}; 
  std::cout << sz << std::endl; // prints address of sz[0]
  Bar().foo(sz);  // prints another address!!
  return 0;
}

Note:
Everything works fine and this erroneous behaviour is NOT observed if
- foo is a non-member template function: 
 template void foo(T);
- foo is a member function with non-generic arguement:
 typedef int arr[3];
 template void Bar::foo(arr a);
- foo is exact same as the code above (member func with generic arguement) but
the  arguement is a reference rather that pass by value 
 template void Bar::foo(T& a);

-- 
   Summary: [wrong-code] template class member function with array
typedef arguement behaves erroneously
   Product: gcc
   Version: 3.4.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: leventyilmaz at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21895


[Bug c++/105518] New: [rejects valid] nested lambda using an outer type alias fails with constexpr integer in that alias

2022-05-07 Thread leventyilmaz at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105518

Bug ID: 105518
   Summary: [rejects valid] nested lambda using an outer type
alias fails with constexpr integer in that alias
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: leventyilmaz at gmail dot com
  Target Milestone: ---

The following valid code is fails to compile. 

https://godbolt.org/z/v1sd9snGx

// Simple run-time to compile-time integer conversion:
template
auto toStatic(int i, F f) {
switch(i) {
case 0: return f( std::integral_constant{} );
case 1: return f( std::integral_constant{} );
case 2: return f( std::integral_constant{} );
default: assert("too big");
}
}


// example types:
struct Base {
virtual void show() const = 0;
};
template  struct F {
template  struct K : Base {
void show() const override {
std::cout << I << " " << J << std::endl;
}
};
};


// nested lambda complains "I" is not captured
// even though it is only being used at compile-time
void show(int i, int j) {
return toStatic(i, [j](auto I) {
using A = F;
// using A = F; // this works
return toStatic(j, [](auto J)  {
using impl = typename A::template K;
impl{}.show();
});
});
}


source>:32:19: error: 'I' is not captured
   32 | using impl = typename A::template K;
  |   ^~~~