https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90005

--- Comment #2 from Pawel <pawel.wrobel at nielsen dot com> ---
Hi,

Thanks, 

Adding -Wformat indeed show up a waring here : 

$ g++ -Wformat main.cpp -o out 
main.cpp: In function ‘int main()’:
main.cpp:6:30: warning: format ‘%s’ expects argument of type ‘char*’, but
argument 2 has type ‘std::string* {aka std::basic_string<char>*}’ [-Wformat=]
   printf("Hello %s ! \n", txt);


I can make it into an error using the -Werror flag then - however - that seems
to be too strict. In the actual, real-scenario code, I think, I cannot afford
to use the -Werror flag globally - since it will turn many of otherwise
harmless warnings into errors.

Is there a reason why this is considered to be 'just a harmless warning' by
newer(>=5.0) gcc - whereas other gcc(<5.0)/complers consider this a "hard
problem" (doing this omission changes program into printing the complete
garbage, so just a warning seems to be a little too soft there)...
The warning/error message also is so different between gcc versions here..

Reply via email to