Bug 62313

Summary: Sources won't compile by ISO C99 compiler
Product: [Retired] Red Hat Linux Reporter: Sysoltsev Slawa <vyatcheslav.sysoltsev>
Component: gettextAssignee: Trond Eivind Glomsrxd <teg>
Status: CLOSED RAWHIDE QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-04-01 22:12:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sysoltsev Slawa 2002-03-29 15:23:02 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Description of problem:
file src/po-lex.h, macro po_gram_error_at_line in case __STDC__ && (defined 
__STDC_VERSION__ && __STDC_VERSION__ >= 199901L:
# define po_gram_error_at_line(pos, fmt, ...)                               \
  do {                                                                      \
    error_at_line (0, 0, (pos)->file_name, (pos)->line_number,              \
                    fmt, __VA_ARGS__);                                      \
    if (*fmt == '.')                                                        \
      --error_message_count;                                                \
    else if (error_message_count >= gram_max_allowed_errors)                \
      error (1, 0, _("too many errors, aborting"));                         \
  } while (0)

This macro produces incorrect code when used only with 2 parameters (when ... 
becomes to nothing) and this happens while compiling msgcmp.c file:
msgcmp.c: In function `compare':
msgcmp.c:255: parse error before `)'
msgcmp.c:257: parse error before `)'
msgcmp.c:276: parse error before `)'
msgcmp.c: In function `compare_directive_message':
msgcmp.c:356: parse error before `)'
msgcmp.c:357: parse error before `)'
Problem is that macro doesn't discard extra comma. I tried to insert ## before 
__VA_ARGS__ and problem disappeared. 
Is this workaround good enough for the most Linux compilers conforming ISO C99?
Better than nothing.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. unpack & configure gettext-0.10.38-7.src.rpm
2. cd BUILD/gettext-0.10.38/src
3. gcc -DLOCALEDIR=\"/usr/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -
I../intl -I../intl    -O2 -march=i386 -mcpu=i686 -c msgcmp.c -std=c99
	

Actual Results:  Compile-time errors:
msgcmp.c: In function `compare':
msgcmp.c:255: parse error before `)'
msgcmp.c:257: parse error before `)'
msgcmp.c:276: parse error before `)'
msgcmp.c: In function `compare_directive_message':
msgcmp.c:356: parse error before `)'
msgcmp.c:357: parse error before `)'


Expected Results:  object file as a result of successful build.

Additional info:

If you provide branches in your sources for ISO C99 compliant compilers why 
these branches aren't work ?

Comment 1 Trond Eivind Glomsrxd 2002-04-01 22:12:28 UTC
Reproduced with 0.11.1, reported upstream as well.

Comment 2 Trond Eivind Glomsrxd 2002-04-05 06:12:06 UTC
Fixed in gettext-0.11.1-2.