http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
Bug ID: 59394 Summary: Unused code generated Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: smal.root at gmail dot com Target: AVR Created attachment 31385 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31385&action=edit source code GCC: avr-gcc -v Using built-in specs. COLLECT_GCC=avr-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.8.2/lto-wrapper Target: avr Configured with: /build/avr-gcc/src/gcc-4.8.2/configure --disable-cloog-version-check --disable-install-libiberty --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-linker-build-id --disable-nls --disable-werror --enable-__cxa_atexit --enable-checking=release --enable-clocale=gnu --enable-cloog-backend=isl --enable-gnu-unique-object --enable-gold --enable-languages=c,c++ --enable-ld=default --enable-lto --enable-plugin --enable-shared --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr --with-as=/usr/bin/avr-as --with-gnu-as --with-gnu-ld --with-ld=/usr/bin/avr-ld --with-plugin-ld=ld.gold --with-system-zlib Thread model: single gcc version 4.8.2 (GCC) OS: Arch Linux Linux 3.12.0-1-ARCH #1 SMP PREEMPT Wed Nov 6 09:06:27 CET 2013 x86_64 GNU/Linux Command line: avr-gcc -Wall -mmcu=atxmega64a3 -DF_CPU=16000000UL -mno-interrupts -Os -pedantic-errors -pedantic -std=c++11 -Wfatal-errors -Wall -I/usr/avr/include -c main.cpp -o obj/Release/main.o main.cpp: In function 'int main()': main.cpp:55:21: warning: variable 'tval32' set but not used [-Wunused-but-set-variable] volatile uint32_t tval32; ^ avr-g++ -o bin/Release/lambda_test.elf obj/Release/main.o -mmcu=atxmega64a3 -Wl,-Map=bin/Release/lambda_test.map,--cref Output size is 7,92 KB Running project post-build steps avr-size bin/Release/lambda_test.elf text data bss dec hex filename 850 0 2400 3250 cb2 bin/Release/lambda_test.elf avr-objdump -h -S bin/Release/lambda_test.elf > bin/Release/lambda_test.lss Process terminated with status 0 (0 minutes, 0 seconds) 0 errors, 1 warnings (0 minutes, 0 seconds) Source file: attached main.cpp Generated assembly: attached lambda_test.lss Problem. A. As you can see in generated assembly: 1. function Sort_OldStyle(_Z13Sort_OldStylev) contain(as inline) functions Sort and Sort_OldStyle_Internal 2. function Sort_NewStyle(_Z13Sort_NewStylev) contain(as inline) functions Sort and lambda-expression B. But also generated code contain unneded: 1. function Sort(_Z4SortPV5SPairS1_PFvRS0_E) 2. function Sort_OldStyle_Internal(_Z22Sort_OldStyle_InternalRV5SPair) 3. lambda-expression(_ZZ13Sort_NewStylevENUlRV5SPairE_4_FUNES1_) Why gcc include functions from B-list if they already exist in functions of list A? Also why gcc use inline for function Sort and don't use call with -Os used?