Ian Lance Taylor Friday, 8 June 2007 1:52 a.m. > > At the very least there should be a compiler option for standard > conformant behaviour in this area. I didn't see one in the MSDN docs. > I would say that gets is much more dangerous than %n in printf, but > presumably Microsoft does not disable gets. >
The MSVCRT version of printf is non-conformant in several ways. In addition to the new '%n' behaviour, there is the old problems with the requirement to use 'I64' format flag in place of 'll', failure to handle long double, non-C99-conformant return value for vsnprintf. I believe that thef first two of these are represented by open GCC Bugzilla PR's. A GCC target option (say, -malt-ISO-printf) for mingw that causes calls to printf family to be mapped to a mingw_printf, mingw_snprintf, etc is one possibilty. I have an experimntal a ISO-C99 compliant mingw_vsnprintf that I was planning to contribute to mingw's libmingex.a runtime extension library. The main reason for writing this was to allow long double output in libstdc++ and libgfortran. Wrapping that in _set_printf_count_output (or adding a ctor that calls _set_printf_count_output to a new startfile object) if we are using Vista's MSVCRT.dll would avoid this problem in genmodes. Although, the alternate versions of *printf could be enabled in other ways, having a compiler switch take care of it would be nice. Danny > Ian >