kern/95987: [patch] nfsproto.h has trailing ',' in enums

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Wed Apr 19 09:11:32 UTC 2006


On Tue, Apr 18, 2006 at 03:46:29PM -0400, Jim Rees wrote:
> Synopsis: [patch] nfsproto.h has trailing ',' in enums
> 
> State-Changed-From-To: open->closed
> State-Changed-By: rees
> State-Changed-When: Tue Apr 18 15:41:22 EDT 2006
> State-Changed-Why: 
> This is explicitly allowed by ANSI C "Enumeration specifiers" which
> says that an enumerator-list may be followed by a comma. Not a bug.
> 

I have only drafts of c89, c99 and c++98 and looks like,
that trailing comma in enum is c99 addition.

c89	3.5.2.2		Enumeration specifiers
c99	6.7.2.2		Enumeration specifiers
c++89	7.2		Enumeration declarations

http://david.tribble.com/text/cdiffs.htm#C99-enum-decl

Simple program:

enum {
	a,
};

int
main(void)
{
	return 0;
}

Results from GCC 3.4.4 and TenDRA 4.0 compilers on 6.1-RC/i386:

% gcc -ansi -pedantic a.c
a.c:3: warning: comma at end of enumerator list

% gcc -std=c99 a.c

% g++ a.cc

% g++ -pedantic a.cc
a.cc:3: error: comma at end of enumerator list

% tcc -Yansi a.c
"a.c", line 3: Error:
  [Syntax]: Extra comma at end of list.

% tcc -Yc++ a.cc
"a.c", line 3: Error:
  [Syntax]: Extra comma at end of list.

% tcc -Yc99 a.c

(I do not know equivalent for -pedantic for g++)


More information about the freebsd-bugs mailing list