[Bug c++/78986] [7/8/9 Regression] template inner classes are not affected by access specifiers

2018-12-14 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78986

Balakrishnan B  changed:

   What|Removed |Added

 CC||balakrishnan.erode at gmail 
dot co
   ||m

--- Comment #2 from Balakrishnan B  ---
This has nothing to do with inheritance. If the inner class is template, access
specifiers are ignored. Simpler example:

class A {
struct B1 {};

template
struct B2 {};
};

void foo() {
//A::B1 b1; //This doesn't compile (GOOD)
A::B2 b2; // This compiles (BAD)
}

Explorer: https://gcc.godbolt.org/z/S0YBPu

Bug is present in all versions between GCC 6.1 to trunk. GCC5 and earlier are
good.

[Bug c++/65143] [C++11] missing devirtualization for virtual base in "final" classes

2016-01-28 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143

Balakrishnan B  changed:

   What|Removed |Added

Version|4.9.2   |5.3.0
  Known to fail||5.3.0
   Severity|normal  |major

[Bug c++/53792] [C++11] improving compiler-time constexpr evaluation

2015-05-06 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53792

Balakrishnan B balakrishnan.erode at gmail dot com changed:

   What|Removed |Added

 CC||balakrishnan.erode at gmail 
dot co
   ||m

--- Comment #8 from Balakrishnan B balakrishnan.erode at gmail dot com ---
Another testcase with c++14 extended constexpr (i.e supports loops and more
than one statement).

Code:

templateclass T
void sink(T);

constexpr unsigned foo(){
  unsigned  i = 1;
  while((i1)  i){
i = i1;
  }
  return i;
}
templateunsigned i
  struct Foo
{
};

void bar(){
  sink(foo());
  sink(Foofoo(){});
}

Assembly for bar: 
clang3.5.1 -O3 -std=c++14
bar():# @bar()
pushq   %rax
movl$-2147483648, %edi  # imm = 0x8000
callq   void sinkunsigned int(unsigned int)
popq%rax
jmp void sinkFoo2147483648u (Foo2147483648u) # TAILCALL

gcc5.1.0 -O3 -std=c++14
bar():
movl$32, %eax
movl$1, %edi
jmp .L2
.L3:
movl%edx, %edi
.L2:
subl$1, %eax
leal(%rdi,%rdi), %edx
jne .L3
subq$8, %rsp
callvoid sinkunsigned int(unsigned int)
subq$8, %rsp
pushq   $0
callvoid sinkFoo2147483648u (Foo2147483648u)
addq$24, %rsp
ret

Live demo: http://goo.gl/b56Q5k


[Bug c++/65143] [C++11] missing devirtualization for virtual base in final classes

2015-03-17 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143

--- Comment #4 from Balakrishnan B balakrishnan.erode at gmail dot com ---
Thanks for confirming!


[Bug c++/65143] [C++11] missing devirtualization for virtual base in final classes

2015-03-13 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143

--- Comment #2 from Balakrishnan B balakrishnan.erode at gmail dot com ---
Can someone please confirm the bug?


[Bug c++/65143] New: [C++11] missing devirtualization for virtual base in final classes

2015-02-20 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143

Bug ID: 65143
   Summary: [C++11] missing devirtualization for virtual base in
final classes
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: balakrishnan.erode at gmail dot com

When a class is marked final, it can devirtualize access to all base classes as
its layout is known. This is missing in gcc. 

struct A
{
  int i();
};

struct B : public virtual A
{
  int get()
  {
return A::i() + 1;
  }
};

struct C final : public B
{
  int get()
  {
return A::i() + 2;
  }
};

int foo(C c)
{  
  return c.get(); // Need not go via vtable pointer as class C is final
}

int foo(B b2)
{
  return b2.get(); // This has to go via vtable as most derived class can
change the location of A
}

Assembly: Both do virtual dispatch

foo(C):
subq$8, %rsp
movq(%rdi), %rax
addq-24(%rax), %rdi
callone::A::i()
addq$8, %rsp
addl$2, %eax
ret
foo(B):
subq$8, %rsp
movq(%rdi), %rax
addq-24(%rax), %rdi
callone::A::i()
addq$8, %rsp
addl$1, %eax
ret

Complete example:
gcc: http://goo.gl/U4KEvj
clang: http://goo.gl/PpQCkd  -- Clang does this optimization


[Bug c++/65143] [C++11] missing devirtualization for virtual base in final classes

2015-02-20 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143

Balakrishnan B balakrishnan.erode at gmail dot com changed:

   What|Removed |Added

 CC||balakrishnan.erode at gmail 
dot co
   ||m
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=49488

--- Comment #1 from Balakrishnan B balakrishnan.erode at gmail dot com ---
I mean access to A::i() can be devirtualized in C::get().


[Bug c++/55914] [C++11] Pack expansion fails in lambda expressions

2014-11-20 Thread balakrishnan.erode at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55914

Balakrishnan B balakrishnan.erode at gmail dot com changed:

   What|Removed |Added

 CC||balakrishnan.erode at gmail 
dot co
   ||m

--- Comment #8 from Balakrishnan B balakrishnan.erode at gmail dot com ---
Is this bug fixed in 4.8.3? I don't find here

Known to work:4.9.0
Known to fail:4.7.2, 4.8.0


[Bug libstdc++/53631] [C++11] regex is unimplemented

2013-03-28 Thread balakrishnan.erode at gmail dot com


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



Balakrishnan B balakrishnan.erode at gmail dot com changed:



   What|Removed |Added



 CC||balakrishnan.erode at gmail

   ||dot com



--- Comment #5 from Balakrishnan B balakrishnan.erode at gmail dot com 
2013-03-28 15:17:16 UTC ---

Why is the priority just normal? I think its very much needed. I wish there was

a vote button for the issues.


[Bug c++/11750] class scope using-declaration lookup not implemented

2011-01-12 Thread balakrishnan.erode at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750

Balakrishnan B balakrishnan.erode at gmail dot com changed:

   What|Removed |Added

 CC||balakrishnan.erode at gmail
   ||dot com

--- Comment #6 from Balakrishnan B balakrishnan.erode at gmail dot com 
2011-01-12 16:57:07 UTC ---
(In reply to comment #0)
 Paragraph 10.3/2 in the C++ standard [ISO/IEC 14882:1998] provides the
 following
 code example:
 
 quote
 
 struct A {
 virtual void f();
 };
 struct B : virtual A {
 virtual void f();
 };
 
 struct C : B , virtual A {
 using A::f; 
 };
 void foo() {
 C c; 
 c.f();  // calls B::f, the final overrider
 c.C::f();   // calls A::f because of the using-declaration
 }
 
 /quote
 
 When a similar program is compiled using G++ 3.3, the method call 'c.f()' in
 function foo() incorrectly invokes A::f and not B::f as specified in the
 standard.
 
 example
 code main.cpp
 #include iostream
 
 struct A {
 virtual void f() { std::cout  A::f()\n; }
 };
 struct B : virtual A {
 virtual void f() { std::cout  B::f()\n; }
 };
 struct C : B, virtual A {
 using A::f;
 };
 
 int main()
 {
 C c;
 c.f();  // ERROR - Incorrectly invokes A::f
 c.C::f();   // OK - Invokes A::f
 }
 /code
 
 build
 $ g++ main.cpp
 
 $ ldd a.out
 libstdc++.so.5 =
 /usr/local/gcc/3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/libstdc++.so.5
 (0x40017000)
 libm.so.6 = /lib/tls/libm.so.6 (0x400e4000)
 libgcc_s.so.1 =
 /usr/local/gcc/3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/libgcc_s.so.1 
 (0x40106000)
 libc.so.6 = /lib/tls/libc.so.6 (0x4200)
 /lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x4000)
 /build
 
 output
 $ ./a.out
 A::f()
 A::f()
 /output
 
 /example

Im using g++ 4.4.5
With the same example with my main function as below,
int main()
{
  C c;
  c.f() // Calls A::f
  C* pc = c;
  pc-f() // Calls B::f
}

With the same object when accessed directly produces different results and when
accessed using a pointer of same type produces a different result. Even if gcc
violates standard, there has to be some proper explanation.