https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79241

            Bug ID: 79241
           Summary: error wen compiling -Os, OK with another optimizations
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: night_ghost at ykoctpa dot ru
  Target Milestone: ---

When I compile this (https://github.com/night-ghost/ardupilot) project with -Os
I got errors

==========
In file included from
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/AP_HAL_Namespace.h:4:0,
                 from
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/AP_HAL.h:6,
                 from
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL_REVOMINI/AnalogIn.cpp:22:
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/utility/functor.h:
In instantiation of 'static constexpr Functor<RetType, Args> Functor<RetType,
Args>::bind(T*) [with T = REVOMINI::REVOMINIAnalogIn; RetType (T::*
method)(Args ...) = &REVOMINI::REVOMINIAnalogIn::_timer_event; RetType = void;
Args = {}]':
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL_REVOMINI/AnalogIn.cpp:48:43:
  required from here
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/utility/functor.h:73:49:
error: could not convert '{obj, method_wrapper<REVOMINI::REVOMINIAnalogIn,
&REVOMINI::REVOMINIAnalogIn::_timer_event>}' from '<brace-enclosed initializer
list>' to 'Functor<void>'
         return { obj, method_wrapper<T, method> };
                                                 ^
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/utility/functor.h:74:5:
error: body of constexpr function 'static constexpr Functor<RetType, Args>
Functor<RetType, Args>::bind(T*) [with T = REVOMINI::REVOMINIAnalogIn; RetType
(T::* method)(Args ...) = &REVOMINI::REVOMINIAnalogIn::_timer_event; RetType =
void; Args = {}]' not a return-statement
     }
     ^
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/utility/functor.h:
In static member function 'static constexpr Functor<RetType, Args>
Functor<RetType, Args>::bind(T*) [with T = REVOMINI::REVOMINIAnalogIn; RetType
(T::* method)(Args ...) = &REVOMINI::REVOMINIAnalogIn::_timer_event; RetType =
void; Args = {}]':
/mnt/disk_d/src/quad-copter/ardu-copter/3.4.2-git/ardupilot.3.4-revo/libraries/AP_HAL/utility/functor.h:74:5:
warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
make: *** [/tmp/ArduCopter.build/libraries/AP_HAL_REVOMINI/AnalogIn.o] Ошибка 1
==============

but all OK with -O0, -Og and -O2

moreover all turns to OK when I change

#include "functor.h"

to 

#pragma GCC push_options
#pragma GCC optimize ("O2")
#include "functor.h"
#pragma GCC pop_options

(https://github.com/night-ghost/ardupilot/blob/RevoMini/libraries/AP_HAL/utility/functor.h)

tested on GCC 4.8.3, 4.9 and 5.4 with same results

Reply via email to