[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] match formats and arguments exactly

From: C.J. Wagenius
Subject: Re: [Tinycc-devel] match formats and arguments exactly
Date: Fri, 21 Jun 2019 17:33:39 +0200 (CEST)

This patch has little to do with the general forrmating functions. Maybe the 
name of the patch is a bit misleading. Pascal are simply casting some values to 
the correct type, that are formatted in error messages. This so that no 
undefined behavior occurs.

Hope this sort things out.


21 juni 2019 17:24 av address@hidden:

> Don't misunderstand me, this check is a very valuable addition. For an
> uncounted number of years I use any possible warnings and my code (almost)
> pass with all sanitizer, splint, code analyzers ...
> You should also understand that many code slowly moved from K&R to ANSI, to
> C98 .. C11 and it's a pain to port from one C version to another especially
> when you're not the original author. 
> If you always do this check, suddenly a code w.o warning you develop with
> tcc will display hundreds or thousands new warnings nobody will have the
> energy to fix (very likely with a ugly cast on the argument).
> Rigid (or pedantic) developers, as I am, certainly would like to activate
> -Wformat and fix incorrect format string. Others, will be very happy to see
> no more warning than they use to have.
> So I personally vote to add this check if it protest only with -Wformat. I
> can also accept it exists only with -std=c11 even if it's not the gcc
> behavior.
> IMHO gcc compatibility (or VC++ on Windows) should be a goal for tcc. We are
> many to use tcc for its fast development cycle but gcc/vc remains the only
> choice for release.
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=address@hidden]
> On Behalf Of ian
> Sent: Friday, June 21, 2019 16:54
> To: address@hidden
> Subject: Re: [Tinycc-devel] match formats and arguments exactly
> Hi Pascal,
> I *know* that (including the no-way part).
> And I *know* too that this misuse is sometimes what's expected by
> developers...
> Anyway, I don't think it's desirable that kinds of pointers are checked.
> Still my humble opinion.
> -- ian (address@hidden)
> -- développeur compulsif
> Le 21/06/2019 à 16:47, Pascal Cuoq a écrit :
> On 21 Jun 2019, at 16:10, ian <address@hidden> wrote:
> Hello,IMHO, considering that flexibility is what I love in C programming,
> and that this checking should be printf job (in that case),
> Unfortunately, this is not how printf, or other variadic functions, work.
> The way they work is: the non-variadic arguments (in the case of printf, the
> format string) indicate what variadic arguments should be consumed with what
> type. If the types of the arguments actually passed do not match the types
> indicated by the non-variadic arguments, the behavior is undefined.
> Not only printf, and other variadic functions, have no obligation to warn
> you if you misuse them, but on every existing platform (including the exotic
> platforms where a pointer is not a pointer), they actually have no way to
> warn you that you are misusing them.
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]