[Bug c++/55958] New: vtable hidden when compiling with -fvisibility-ms-compat

2013-01-12 Thread gnu at gonsoe dot com


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



 Bug #: 55958

   Summary: vtable hidden when compiling with

-fvisibility-ms-compat

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: g...@gonsoe.com





Created attachment 29153

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29153

so1.h, so1.cxx, main.cxx, Makefile + compiler --save-temp files.  Build with

'make main'



% gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper

Target: i686-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs

--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr

--program-suffix=-4.7 --enable-shared --enable-linker-build-id

--with-system-zlib --libexecdir=/usr/lib --without-included-gettext

--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7

--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu

--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object

--enable-plugin --enable-objc-gc --enable-targets=all --disable-werror

--with-arch-32=i686 --with-tune=generic --enable-checking=release

--build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu

Thread model: posix

gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 





The vtable for a class with a virtual member function is HIDDEN when source

file is compiled with -fvisibility-ms-compat. If a shared library is created

from the object file, then clients of the shared library cannot construct

objects of the class without getting an undefined symbol for the vtable. 



% cat so1.h

#ifdef SO1_SOURCE

# define EXPORT __attribute ((visibility("default")))

#else

# define EXPORT

#endif



class SO1

{

 public:

  EXPORT virtual void foo();

};



% cat so1.cxx

#define SO1_SOURCE

#include "so1.h"

void SO1::foo() {}



% g++ -c so1.cxx -fvisibility-ms-compat

% eu-readelf -s so1.o | c++filt|grep SO1

   14:   5 FUNCGLOBAL DEFAULT4 SO1::foo()

   15:  12 OBJECT  WEAK   HIDDEN 7 vtable for SO1

   16:   8 OBJECT  WEAK   DEFAULT9 typeinfo for SO1

   18:   5 OBJECT  WEAK   DEFAULT   11 typeinfo name for SO1



% g++ -shared -o libso1.so so1.o



% cat main.cxx

#include "so1.h"

int main()

{

  SO1 so1;

  return 0;

}



% g++ main.cxx -L. -lso1

/tmp/ccLfT7tK.o: In function `SO1::SO1()':

main.cxx:(.text._ZN3SO1C2Ev[_ZN3SO1C5Ev]+0x8): undefined reference to `vtable

for SO1'

collect2: error: ld returned 1 exit status


[Bug c++/55958] vtable hidden when compiling with -fvisibility-ms-compat

2013-01-12 Thread gnu at gonsoe dot com


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



--- Comment #2 from Soren Soe  2013-01-13 00:16:11 UTC 
---

Unfortunately this is a both a Linux and Windows project.  I would like to

reuse the windows export macros, have gcc default to -fvisibility-ms-compat so

that everything except typeinfo and supposedly vtable is marked hidden, then

explicitly export only what needs to be exported.  My understanding is that

-fvisibility-ms-compat is exactly for that purpose, but the hidden vtable is

not consistent with windows.


[Bug libstdc++/69116] New: compile error when including valarray

2016-01-01 Thread gnu at gonsoe dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69116

Bug ID: 69116
   Summary: compile error when including valarray
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gnu at gonsoe dot com
  Target Milestone: ---

The following code does not compile with gcc4.8.4 or gcc5.2.1.  I have access
to an older 4.8.0 compiler where the code compiles ok, so this appears to be a
regression.  

The inclusion of  causes the compile error.

#include 
#include 

struct x : public std::ostream
{
  virtual void flush() = 0;
};
void foo(x& os)
{
  os << std::endl;
}

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.4-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++11' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE va.cxx -mtune=generic -march=x86-64 -std=c++11
-fpch-preprocess -fstack-protector -Wformat -Wformat-security -o va.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.8
 /usr/include/x86_64-linux-gnu/c++/4.8
 /usr/include/c++/4.8/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++11' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -fpreprocessed va.ii -quiet
-dumpbase va.cxx -mtune=generic -march=x86-64 -auxbase va -std=c++11 -version
-fstack-protector -Wformat -Wformat-security -o va.s
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu)
compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu)
compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9cb21c615435621dce26fe5e793192fd
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray: In instantiation of ‘class std::valarray’:
va.cxx:10:14:   required from here
/usr/include/c++/4.8/valarray:926:5: error: cannot allocate an object of
abstract type ‘x’
 valarray<_Tp>::sum() const
 ^
va.cxx:4:8: note:   because the following virtual functions are pure within
‘x’:
 struct x : public std::ostream
^
va.cxx:6:16: note:  virtual void x::flush()
   virtual void flush() = 0;
^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1033:5: error: cannot allocate an object of
abstract type ‘x’
 valarray<_Tp>::min() const
 ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1041:5: error: cannot allocate an object of
abstract type ‘x’
 valarray<_Tp>::max() const
 ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual function

[Bug middle-end/99689] Initialized local variable becomes uninitialized after use

2021-03-22 Thread gnu at gonsoe dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99689

Soren Soe  changed:

   What|Removed |Added

 CC||gnu at gonsoe dot com

--- Comment #5 from Soren Soe  ---
I've tried all options.  Fails only when compiled with -O3.

I looked at assembler code on https://godbolt.org, and it appears that with ARM
gcc9.3 the unsigned int variable is not initialized.  The assembler code is
very different if unsigned int is replaced with size_t, or when using -O2, and
appears to show a variable initialized to 0.

void
good()
{
  vec v;
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");

  size_t m = 0;
  for (auto& p : v)
m = std::max(m, p.first.length());

  assert(m==3);
}

void
bad()
{
  vec v;
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");

  unsigned int m = 0;
  for (auto& p : v)
m = std::max(m, p.first.length());

  assert(m==3);
}

[Bug middle-end/99689] Initialized local variable becomes uninitialized after use

2021-03-22 Thread gnu at gonsoe dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99689

--- Comment #6 from Soren Soe  ---
I should maybe mention that the same problem is reproducible using qemu-aarch64
and qemu-aarch64-static on an x86_64 host.

% aarch64-linux-gnu-g++ -O3 -static bug.cpp
% qemu-aarch64-static ./a.out 
a.out: bug.cpp:78: void bad(): Assertion `m == 3' failed.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted (core dumped)

Works fine with -O2 or the size_t variant I mentioned.

% aarch64-linux-gnu-g++ -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9 --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --without-target-system-zlib
--enable-libpth-m2 --enable-multiarch --enable-fix-cortex-a53-843419
--disable-werror --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=aarch64-linux-gnu
--program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)