[Bug c++/70182] c++filt fails to demangle symbol

2019-09-30 Thread gdutor at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70182

Fenglin Hou  changed:

   What|Removed |Added

 CC||gdutor at gmail dot com

--- Comment #16 from Fenglin Hou  ---
FYI.

```
$ c++filt --version
GNU c++filt version 2.31.1-29.fc30
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

$ c++filt
_ZZZN6nebula4meta11AdminClient11getResponseINS_7storage4cpp215MemberChangeReqEZNS1_12memberChangeEiiRKSt4pairIiiEbE3$_7EEvSt6vectorIS7_SaIS7_EEiT_T0_iN5folly7PromiseINS_6StatusEEEiENUlvE_clEvENUlONSG_3TryINS4_13AdminExecResp_clESO_
_ZZZN6nebula4meta11AdminClient11getResponseINS_7storage4cpp215MemberChangeReqEZNS1_12memberChangeEiiRKSt4pairIiiEbE3
```

[Bug c++/82560] New: Temporary object created as a default argument not destructed

2017-10-15 Thread gdutor at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82560

Bug ID: 82560
   Summary: Temporary object created as a default argument not
destructed
   Product: gcc
   Version: 7.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gdutor at gmail dot com
  Target Milestone: ---

Created attachment 42374
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42374&action=edit
Source code that reproduce the bug

This is the code trigger the leaking bug.
=
#include 
#include 
#include 

class Foo {
public:
Foo(const char *str) : str_(str) {
std::cout << "Foo(const char*)" << std::endl;
}
Foo(const Foo&) {
std::cout << "Foo(const Foo&)" << std::endl;
}
~Foo() {
std::cout << "~Foo()" << std::endl;
}
std::string str_;
};

class Bar {
public:
Bar(Foo foo = "implicitly casted to Foo") : foo_(foo) {
std::cout << "Bar(Foo)" << std::endl;
}
~Bar() {
std::cout << "~Bar()" << std::endl;
}

Foo foo_;
};

int main()
{
auto ptr = std::make_unique();
return 0;
}
=

Compile and run it:
=
$ g++ -std=c++14 leak.cpp
$ ./a.out
Foo(const char*)
Foo(const Foo&)
Bar(Foo)
~Bar()
~Foo()
=

As the outputs indicate, two Foo objects are created, while the destructor of
Foo invoked only once.

Here is what g++ -v prints:
=
Using built-in specs.
COLLECT_GCC=third-party/gcc-7.1.0/glibc-2.17/bin/g++
COLLECT_LTO_WRAPPER=/data/admin/Workspace/third-party/gcc-7.1.0/glibc-2.17/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: third-party/gcc-7.1.0/source/gcc-7.1.0/configure
--prefix=third-party/gcc-7.1.0/glibc-2.17
--with-gmp=third-party/gcc-7.1.0/../gmp-6.1.2/glibc-2.17
--with-mpfr=third-party/gcc-7.1.0/../mpfr-3.1.6/glibc-2.17
--with-mpc=third-party/gcc-7.1.0/../mpc-1.0.3/glibc-2.17 --without-isl
--enable-static-libjava --disable-multiarch --disable-multilib
--enable-languages=c,c++,go --disable-libada --disable-libvtv
--enable-default-pie --disable-nls --disable-lto
Thread model: posix
gcc version 7.1.0 (GCC)
=

[Bug c++/99952] New: Incompatible function call ABI between 7.5 and 9.2

2021-04-07 Thread gdutor at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99952

Bug ID: 99952
   Summary: Incompatible function call ABI between 7.5 and 9.2
   Product: gcc
   Version: 7.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gdutor at gmail dot com
  Target Milestone: ---

For such a snipet, g++-7.5.0 and g++-9.2.0 generate different ABI for function
`foo`:
```
#include 

enum E {
kA,kB,kC,kD,kE,kF
};

struct S {
E e;
std::optional o;
};

void foo(S s) {
fprintf(stderr, "%d\n", (int)s.e);
}

int main() {
S s;
foo(s);
return 0;
}
```
7.5.0:
```
Dump of assembler code for function foo(S):
   0x00400767 <+0>: push   %rbp
   0x00400768 <+1>: mov%rsp,%rbp
   0x0040076b <+4>: sub$0x10,%rsp
   0x0040076f <+8>: mov%rdi,-0x8(%rbp)
   0x00400773 <+12>:mov-0x8(%rbp),%rax
   0x00400777 <+16>:mov(%rax),%eax
   0x00400779 <+18>:mov%eax,%edx
   0x0040077b <+20>:mov0x2008de(%rip),%rax# 0x601060

   0x00400782 <+27>:mov$0x400a3c,%esi
   0x00400787 <+32>:mov%rax,%rdi
   0x0040078a <+35>:mov$0x0,%eax
   0x0040078f <+40>:callq  0x400650 
   0x00400794 <+45>:nop
   0x00400795 <+46>:leaveq
   0x00400796 <+47>:retq
```
9.2.0:
```
Dump of assembler code for function foo(S):
   0x00401152 <+0>: push   %rbp
   0x00401153 <+1>: mov%rsp,%rbp
   0x00401156 <+4>: sub$0x10,%rsp
   0x0040115a <+8>: mov%rdi,%rdx
   0x0040115d <+11>:mov%esi,%eax
   0x0040115f <+13>:mov%rdx,-0x10(%rbp)
   0x00401163 <+17>:mov%eax,-0x8(%rbp)
   0x00401166 <+20>:mov-0x10(%rbp),%eax
   0x00401169 <+23>:mov%eax,%edx
   0x0040116b <+25>:mov0x2eee(%rip),%rax# 0x404060

   0x00401172 <+32>:mov$0x402004,%esi
   0x00401177 <+37>:mov%rax,%rdi
   0x0040117a <+40>:mov$0x0,%eax
   0x0040117f <+45>:callq  0x401040 
   0x00401184 <+50>:nop
   0x00401185 <+51>:leaveq
   0x00401186 <+52>:retq

```

Such an incompatibility issue causes a program crash when the program is
compiled by g++ 9.2.0, and linked against a library which is compiled by g++
7.5.0

[Bug c++/99952] Incompatible function call ABI between 7.5 and 9.2

2021-04-07 Thread gdutor at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99952

--- Comment #1 from Fenglin Hou  ---
I wonder if this is a bug, or I missed some compile option.

[Bug c++/99952] Incompatible function call ABI between 7.5 and 9.2

2021-04-07 Thread gdutor at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99952

--- Comment #4 from Fenglin Hou  ---
Thanks for the quick reply.