Bug 5160 - bfd/elflink.c with native HP cc: error #2028: expression must have a constant value
Summary: bfd/elflink.c with native HP cc: error #2028: expression must have a constant...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-10 19:38 UTC by Michael Haubenwallner
Modified: 2007-10-12 16:24 UTC (History)
1 user (show)

See Also:
Host: ia64-hp-hpux11.23
Target: ia64-hp-hpux11.23
Build: ia64-hp-hpux11.23
Last reconfirmed:


Attachments
Remove use of bufsz variable from eval_symbol() (560 bytes, patch)
2007-10-12 16:22 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Haubenwallner 2007-10-10 19:38:24 UTC
When building binutils-2.18 with HP AnsiC compiler, which does not build C99 by
default, besides many warnings there is one error:

/source/binutils-2.18/bfd/elflink.c", line 7378: error #2028: expression must
have a constant value
    char          symbuf [bufsz];

Using an enum for bufsz instead of const int will work here:

--- binutils-2.18/bfd/elflink.c.orig    2007-10-10 21:23:09.148839000 +0200
+++ binutils-2.18/bfd/elflink.c 2007-10-10 21:23:59.117386000 +0200
@@ -7374,7 +7374,7 @@
   int           symlen;
   bfd_vma       a;
   bfd_vma       b;
-  const int     bufsz = 4096;
+  enum { bufsz = 4096 };
   char          symbuf [bufsz];
   const char *  symend;
   bfd_boolean   symbol_is_section = FALSE;
Comment 1 Nick Clifton 2007-10-12 16:22:29 UTC
Created attachment 2040 [details]
Remove use of bufsz variable from eval_symbol()
Comment 2 Nick Clifton 2007-10-12 16:24:52 UTC
Hi Michael,

  Actually there is no need for the bufsz variable at all.  It is cleaner just
to give the symbuf array a constant size and then refer to 'sizeof (symbuf)' in
the code.  So that is what the uploaded patch does, and this is what I will be
checking in.

Cheers
  Nick

bfd/ChangeLog
2007-10-12  Nick Clifton  <nickc@redhat.com>

	PR 5160
	* elflink.c (eval_symbol): Remove bufsz variable and use
	sizeof(symbuf) where necessary.