This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] std::string(0);
Martin Sebor wrote:
A conforming implementation is not allowed to reject constructs
such as std::string (0) just because they might cause undefined
behavior at runtime. Consider this well-formed program:
#include <string>
int main () {
if (0) std::string (0);
}
Martin
OK, so this means we can't go the "easy" way. The remaining options are
(AFAICS):
a) Change the standard, make the above example illegal. Unlikely.
b) Ask the compiler folks to detected these cases and emit a warning.
Bonus points for suppressing the warning on dead code branches like
above. Sadly, I suppose it's ways more work than adding one or two lines
to the STL implementation. Any volunteers? ;)
Thanks anyway for your help. At least I know I will get better run-time
messages when I finally manage to get rid of the GCC 2.95.2... 8-)
Regards, Daniel
--
Daniel Frey
aixigo AG - financial solutions & technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey@aixigo.de, web: http://www.aixigo.de