[Bug demangler/93035] New: Found 91 mangled names which do not demangle using c++filt

2019-12-20 Thread simonhf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93035

Bug ID: 93035
   Summary: Found 91 mangled names which do not demangle using
c++filt
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: demangler
  Assignee: unassigned at gcc dot gnu.org
  Reporter: simonhf at gmail dot com
  Target Milestone: ---

The list of mangled names failing to demangle with c++filt is here [1]. They
also fail to demangle with the independently implemented c++filt.go [2].
However, they all demangle okay using llvm-cxxfilt [3].

$ llvm-cxxfilt --version | egrep version
  LLVM version 9.0.0

[1] https://github.com/ianlancetaylor/demangle/issues/10
[2] https://github.com/ianlancetaylor/demangle
[3] https://llvm.org/docs/CommandGuide/llvm-cxxfilt.html

[Bug demangler/93035] Found 91 mangled names which do not demangle using c++filt

2019-12-31 Thread simonhf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93035

--- Comment #1 from Simon Hardy-Francis  ---
Also, for names which do demangle then there are wide spread differences [1] if
the same name is demangled using llvm-cxxfilt. I tried out demangling over 100k
mangled names with both tools here [1].

[1] https://gist.github.com/simonhf/0d60bb94f2d90c1b32e4786b2d1062ad

[Bug c++/93475] New: With 100k+ mangled names, appears to incorrectly mangle about 15% causing demangle failure

2020-01-27 Thread simonhf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93475

Bug ID: 93475
   Summary: With 100k+ mangled names, appears to incorrectly
mangle about 15% causing demangle failure
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: simonhf at gmail dot com
  Target Milestone: ---

When looking at over 100k mangled C++ names, many of them fail to demangle
using common command line tools. Initially I thought this was the fault of the
demangler and opened a bug here [1]. However, after opening a similar bug here
[2] for the LLVM demangler, a detailed response from LLVM developers appears to
suggest that g++ itself is mangling incorrect, so I opened this bug!

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93035
[2] https://bugs.llvm.org/show_bug.cgi?id=44428

[Bug c++/93475] With 100k+ mangled names, g++ appears to incorrectly mangle about 15% causing demangle failure

2020-01-28 Thread simonhf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93475

--- Comment #2 from Simon Hardy-Francis  ---
The other two links posted link to this gist [1] which contains a list of the
presumably incorrectly mangled names which fail  to demangle. The mangled names
were harvested from g++ assembly files after compiling this open source project
called Zeek [2].

Link [1] contains the list of mangled names which fail to demangle and which
the LLVM guys suggest were incorrectly mangled in the first place. If you'd
like to recreate the list then recompile Zeek [2] via assembly files and then
harvest the mangled names from the assembly files. Friendly warning: Many of
the mangled names are many KB long, and many of the demangled names are many
100 KB long due to gratuitous C++ templating!

Good luck!

[1] https://gist.github.com/simonhf/0d60bb94f2d90c1b32e4786b2d1062ad
[2] https://github.com/zeek/zeek

[Bug rtl-optimization/47712] New: optimization (-O) of code using union unexpectedly causes essential code to be optimized away

2011-02-12 Thread simonhf at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47712

   Summary: optimization (-O) of code using union unexpectedly
causes essential code to be optimized away
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: simo...@gmail.com


Reproduce with:

mingw32-gcc.exe -DWITH_UNNECESSARY_CODEexample.c -oexample.exe &&
example.exe
mingw32-gcc.exeexample.c -oexample.exe &&
example.exe
mingw32-gcc.exe -DWITH_UNNECESSARY_CODE -O example.c -oexample.exe &&
example.exe
mingw32-gcc.exe -O example.c -oexample.exe &&
example.exe

Shows output:

C:\20110211-gcc-bug>mingw32-gcc.exe -DWITH_UNNECESSARY_CODEexample.c
-oexample.exe   && example.exe
before  copy_bytes(): source : abcd
before  copy_bytes(): destination: 1234
calling copy_bytes(): copy source to destination
after   copy_bytes(): source : abcd
after   copy_bytes(): destination: abcd <-- expected

C:\20110211-gcc-bug>mingw32-gcc.exeexample.c
-oexample.exe   && example.exe
before  copy_bytes(): source : abcd
before  copy_bytes(): destination: 1234
calling copy_bytes(): copy source to destination
after   copy_bytes(): source : abcd
after   copy_bytes(): destination: abcd <-- expected

C:\20110211-gcc-bug>mingw32-gcc.exe -DWITH_UNNECESSARY_CODE -O example.c
-oexample.exe   && example.exe
before  copy_bytes(): source : abcd
before  copy_bytes(): destination: 1234
calling copy_bytes(): copy source to destination
after   copy_bytes(): source : abcd
after   copy_bytes(): destination: abcd <-- expected

C:\20110211-gcc-bug>mingw32-gcc.exe -O example.c
-oexample.exe   && example.exe
before  copy_bytes(): source : abcd
before  copy_bytes(): destination: 1234
calling copy_bytes(): copy source to destination
after   copy_bytes(): source : abcd
after   copy_bytes(): destination: 1234 <-- not expected: the bug in action

example.c:

#include 
#include 

typedef union PTR_UNION
{
char * as_s08_ptr;
unsigned int as_u32;
} PTR_UNION;

void copy_bytes(unsigned int address_as_u32, char * source, unsigned int size)
{
unsigned int i;
PTR_UNION destination;

destination.as_u32 = address_as_u32;

for (i=0 ; i= 1) && (destination.as_s08_ptr[0] != source[0])) {
exit(1);
}
#endif
}

void main(void)
{
PTR_UNION address;
char source[] = "abcd";
char destination[] = "1234";

printf("before  copy_bytes(): source : %s\n", source);
printf("before  copy_bytes(): destination: %s\n", destination);

printf("calling copy_bytes(): copy source to destination\n");
address.as_s08_ptr = destination;
copy_bytes(address.as_u32, source, sizeof(source));

printf("after   copy_bytes(): source : %s\n", source);
printf("after   copy_bytes(): destination: %s <-- %s\n", destination,
strcmp(source, destination) ? "not expected: the bug in action" : "expected");
}

Workaround:

If you find this bug but want to continue compiling your code with the -O
command line option then there are several workarounds:
1. Don't use the union :-)
2. Add the unnecessary code shown above.