warnings in filesystem lib

When compiling following program against the CVS HEAD: #include <boost/filesystem/operations.hpp> int main() { boost::filesystem::path p1("foo") ; boost::filesystem::path p2("bar") ; boost::filesystem::create_symlink(p1,p2) ; return 0 ; } I get following warnings with g++ 3.2.3 In file included from foo.cpp:1: /home/tk/boost/boost/filesystem/operations.hpp: In function `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type boost::filesystem::create_hard_link(const Path&, const Path&)': /home/tk/boost/boost/filesystem/operations.hpp:416: warning: no return statement in function returning non-void /home/tk/boost/boost/filesystem/operations.hpp: In function `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type boost::filesystem::create_symlink(const Path&, const Path&)': /home/tk/boost/boost/filesystem/operations.hpp:440: warning: no return statement in function returning non-void /home/tk/boost/boost/filesystem/operations.hpp: In function `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type boost::filesystem::rename(const Path&, const Path&)': /home/tk/boost/boost/filesystem/operations.hpp:485: warning: no return statement in function returning non-void /home/tk/boost/boost/filesystem/operations.hpp: In function `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type boost::filesystem::copy_file(const Path&, const Path&)': /home/tk/boost/boost/filesystem/operations.hpp:496: warning: no return statement in function returning non-void /home/tk/boost/boost/filesystem/operations.hpp: In function `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type boost::filesystem::last_write_time(const Path&, long int)': /home/tk/boost/boost/filesystem/operations.hpp:574: warning: no return statement in function returning non-void First of all, what concerns me is that the warning is not correct. Nevertheless we can easily make the warning go away by applying the patch in attachment (which semantically has no effect at all). I would therefore like to ask if it would be OK to apply the patch in attachment. toon ? operations.hpp.diff Index: operations.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/filesystem/operations.hpp,v retrieving revision 1.29 diff -u -r1.29 operations.hpp --- operations.hpp 9 Mar 2006 22:14:08 -0000 1.29 +++ operations.hpp 26 Sep 2006 09:46:01 -0000 @@ -413,6 +413,7 @@ boost::throw_exception( basic_filesystem_error<Path>( "boost::filesystem::create_hard_link", to_ph, from_ph, result ) ); + return ; } BOOST_FS_FUNC(system_error_type) @@ -437,6 +438,7 @@ boost::throw_exception( basic_filesystem_error<Path>( "boost::filesystem::create_symlink", to_ph, from_ph, result ) ); + return ; } BOOST_FS_FUNC(system_error_type) @@ -482,6 +484,7 @@ boost::throw_exception( basic_filesystem_error<Path>( "boost::filesystem::rename", from_path, to_path, result ) ); + return ; } BOOST_FS_FUNC(void) copy_file( const Path & from_path, const Path & to_path ) @@ -493,6 +496,7 @@ boost::throw_exception( basic_filesystem_error<Path>( "boost::filesystem::copy_file", from_path, to_path, result ) ); + return ; } template< class Path > @@ -571,6 +575,7 @@ new_time )) != 0 ) boost::throw_exception( basic_filesystem_error<Path>( "boost::filesystem::last_write_time", ph, result ) ); + return ; } # ifndef BOOST_FILESYSTEM_NARROW_ONLY

Toon Knapen <toon.knapen@fft.be> writes: | When compiling following program against the CVS HEAD: | | #include <boost/filesystem/operations.hpp> | int main() | { | boost::filesystem::path p1("foo") ; | boost::filesystem::path p2("bar") ; | boost::filesystem::create_symlink(p1,p2) ; | return 0 ; | } | | I get following warnings with g++ 3.2.3 | | In file included from foo.cpp:1: | /home/tk/boost/boost/filesystem/operations.hpp: In function | `boost::enable_if<boost::filesystem::is_basic_path<Path>, void>::type | boost::filesystem::create_hard_link(const Path&, const Path&)': [...] | First of all, what concerns me is that the warning is not correct. | Nevertheless we can easily make the warning go away by applying the | patch in attachment (which semantically has no effect at all). | | I would therefore like to ask if it would be OK to apply the patch in | attachment. Would the warning go away if throw_exception was marked with a gcc extension "no_return"? If that is easy to accomplish, then we would have a solution that does not "pollute" the code. (except at the decl of throw_exception) boost::throw_exception(...) __attribute__ ((__noreturn__)); -- Lgb

Lars Gullik Bjønnes wrote:
Would the warning go away if throw_exception was marked with a gcc extension "no_return"?
If that is easy to accomplish, then we would have a solution that does not "pollute" the code. (except at the decl of throw_exception)
boost::throw_exception(...) __attribute__ ((__noreturn__));
FWIW, VC++ supports the __declspec(noreturn) for this purpose since _MSC_VER
= 1200.
Regards Hartmut
participants (3)
-
Hartmut Kaiser
-
larsbj@gullik.net
-
Toon Knapen