[Bug c++/37765] Printf of typed null pointer causes a run-time error
hosoda-t at palette dot plala dot or dot jp
gcc-bugzilla@gcc.gnu.org
Wed Oct 8 23:03:00 GMT 2008
------- Comment #2 from hosoda-t at palette dot plala dot or dot jp 2008-10-08 23:02 -------
(In reply to comment #1)
> "%s" requires a pointer to a string, which (char*)0 isn't.
"%s" is a c-style string.
try the code below, and please notice that the code works well on g++ 3.4.4 and
also on Microsoft Visual C++ 2005 without a run-time error.
#include <cstdio>
int main()
{
const char* p = "This is a c-syle string.";
printf("%s\n", p);
char* q = 0;
printf("%s\n", q);
}
--
hosoda-t at palette dot plala dot or dot jp changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37765
More information about the Gcc-bugs
mailing list