[RFC] std::string(0);

Daniel Frey daniel.frey@aixigo.de
Fri Jun 11 17:51:00 GMT 2004


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




More information about the Libstdc++ mailing list