[program_options] warning in options_description::find_nothrow

w.r.t boost HEAD and GCC 4.2.1 in function find_nothrow (line 298) the following fragment appear: if (approximate_matches.size() > 1) boost::throw_exception( ambiguous_option(name, approximate_matches)); else return found.get(); GCC issues a warning about control flow reaching the end of a non-void function. boost::throw_exception is visible to the compiler and it could determine that it _always_ throws. But GCC doesn't. For GCC (and probably the Intel compiler) it would be possible to attach an __attribute__((noreturn)) to the declaration of throw_exception, but this wouldn't be portable. Would it be acceptable to return a fake pointer after the call to throw_exception? We know we'd never get there and the warning would be turned off, a big plus for those using boost in a local directory and insisting on compiling with -Wall and -Werror. Best regards, Maurizio

Simply removing the else would simplify the control flow, and make the compiler happy. if (approximate_matches.size() > 1) boost::throw_exception( ambiguous_option(name, approximate_matches)); // else return found.get(); Corrado On Nov 17, 2007 1:07 AM, Maurizio Vitale <mav@thor.polymath-solutions.lan> wrote:
w.r.t boost HEAD and GCC 4.2.1
in function find_nothrow (line 298) the following fragment appear:
if (approximate_matches.size() > 1) boost::throw_exception( ambiguous_option(name, approximate_matches)); else return found.get();
GCC issues a warning about control flow reaching the end of a non-void function.
boost::throw_exception is visible to the compiler and it could determine that it _always_ throws. But GCC doesn't. For GCC (and probably the Intel compiler) it would be possible to attach an __attribute__((noreturn)) to the declaration of throw_exception, but this wouldn't be portable.
Would it be acceptable to return a fake pointer after the call to throw_exception? We know we'd never get there and the warning would be turned off, a big plus for those using boost in a local directory and insisting on compiling with -Wall and -Werror.
Best regards,
Maurizio
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- __________________________________________________________________________ dott. Corrado Zoccolo mailto:zoccolo@di.unipi.it PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
participants (2)
-
Corrado Zoccolo
-
Maurizio Vitale