https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78247
Bug ID: 78247 Summary: Unused inline function returning u32string causes u32string debuginfo to be emitted. Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: toojays at toojays dot net Target Milestone: --- Consider the following source, compiled with and without MORE_BLOAT defined: jscott@citra:~/src/debuginfo-bloat$ cat bloat-string.cpp #include <string> #ifdef MORE_BLOAT inline std::u32string f(const char32_t* __str, size_t __len) { return std::u32string{__str, __len}; } #endif jscott@citra:~/src/debuginfo-bloat$ g++-6 -std=c++11 -gdwarf-4 -c bloat-string.cpp -o bloat-string.o jscott@citra:~/src/debuginfo-bloat$ g++-6 -DMORE_BLOAT -std=c++11 -gdwarf-4 -c bloat-string.cpp -o bloat-string-more.o jscott@citra:~/src/debuginfo-bloat$ ls -l bloat-string.o bloat-string-more.o -rw-rw-r-- 1 jscott jscott 61256 Nov 8 13:58 bloat-string-more.o -rw-rw-r-- 1 jscott jscott 24672 Nov 8 13:58 bloat-string.o I.e. if I have an inline function refering to u32string it bloats my output object by 40K, even though I never used that function. The extra space seems to go toward debug info for u32string and its associated char_traits. In effect this occurs whenever someone switches from -std=c++11 to -std=c++14, because of the inline string literal operators at the end of basic_string.h. I originally noticed this because switching from -std=c++11 to -std=c++14 increased the size of generated binaries. Discussion at <https://gcc.gnu.org/ml/gcc-help/2016-11/msg00006.html>. I tried to create a smaller example (i.e. not requiring <string>), but couldn't figure out how. The only types I have seen affected by this problem so far are u16string and u32string. My test setup: jscott@citra:~/src/debuginfo-bloat$ gcc-6 -v Using built-in specs. COLLECT_GCC=gcc-6 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.2.0-3ubuntu11~14.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --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=gcc4-compatible --disable-libstdcxx-dual-abi --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --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-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-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 --enable-multilib --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 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~14.04)