Le mercredi 2 novembre 2011 17:29:13, Robert Clausecker a écrit : > Am Mittwoch, den 02.11.2011, 12:00 -0400 schrieb Ben Bacarisse > > > > It seems that I discovered a bug in tcc. ANSI C allows declaration > > > > of > > > > > prototypes containing function pointers like this: > > > void traverse(mystruct_t*, void(mycontent_t*)); > > > > > > tcc currently rejects this giving an error "')' expected". This > > > > > > equivalent prototype works: > > > void traverse(mystruct_t*,void(*)(mycontent_t*)); > > > > > > Is this a bug or a feature? > > > > The two prototypes are not equivalent. The first is a syntax error > > but > > the second one is fine -- provided you wanted to pass a pointer to a > > function that takes a mycontent_t pointer and returns nothing. > > I asked some folks on #c on freenode and they told me to tell you that > section 3.5.4.3, paragraph 9 of the C89 standard specifies that this is > allowed. (Why else would both gcc and clang allow the first declaration > with or without the -std=c89 or -ansi flag?) Quote: > > For each parameter declared with function or array type, its > type for these comparisons is the one that results from > conversion to a pointer type, as in $3.7.1. This seems to correspond to §15 in section 6.7.5.3 in C99 standard. Since C99 is easier to find online, I believe it's worth mentionning. > > I am not an expert on the C spec, but please have a look at it. > > Here is an easier testcase that compiles: > > int foo(int,int,int(int,int)); > int foo(int a,int b,int f(int,int)) { return f(a,b); } > > Yours, Robert Clausecker > > > _______________________________________________ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel