[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-29 Thread pepeto

Update of bug #14387 (project freeciv):

  Status:None => Fixed  
 Assigned to:None => pepeto 
 Open/Closed:Open => Closed 

___

Follow-up Comment #7:

I've tested only my patch (the first one), but it looks like all three would
work. I like the third most, because it only has integer math.

Then I commit it immediately, as it is a compilation failure.


___

Reply to this item at:

  

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-28 Thread Elmo Todurov

Follow-up Comment #4, bug #14387 (project freeciv):

I've tested only my patch (the first one), but it looks like all three would
work. I like the third most, because it only has integer math.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-28 Thread pepeto

Follow-up Comment #3, bug #14387 (project freeciv):

What do you think of my patch, does it works for you?  Then, I would commit
one of those patch as soon as possible.

Index: server/console.c
===
--- server/console.c(révision 16001)
+++ server/console.c(copie de travail)
@@ -136,7 +136,7 @@
 void con_write(enum rfc_status rfc_status, const char *message, ...)
 {
   /* First buffer contains featured text tags */
-  static char buf1[(int)trunc(MAX_LEN_CONSOLE_LINE * 1.5)];
+  static char buf1[(MAX_LEN_CONSOLE_LINE * 3) / 2];
   static char buf2[MAX_LEN_CONSOLE_LINE];
   va_list args;
 

(file #6821)
___

Additional Item Attachment:

File name: trunk_S2_2_compile_error.diff  Size:0 KB


___

Reply to this item at:

  

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-28 Thread Marko Lindqvist

Follow-up Comment #2, bug #14387 (project freeciv):

Ah, sorry. Your patch left cast there so it should be ok after all.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-28 Thread Marko Lindqvist

Follow-up Comment #1, bug #14387 (project freeciv):

> trunc() seems completely bogus here.
>
> The fix is simple enough: 

No to both.

console.c:139: error: size of array ‘buf1’ has non-integer type

But I don't see why these buffers do have 'static' storage duration. Their
content is never reused so no gain there. Patch attached.


(file #6816)
___

Additional Item Attachment:

File name: ConWriteNonStaticBufs_14387.diff Size:0 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #14387] Array declaration is not compile-time constant

2009-09-28 Thread Elmo Todurov

URL:
  

 Summary: Array declaration is not compile-time constant
 Project: Freeciv
Submitted by: elmo
Submitted on: Monday 09/28/2009 at 15:24
Category: None
Severity: 2 - Minor
Priority: 5 - Normal
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Release: 
 Discussion Lock: Any
Operating System: None
 Planned Release: None

___

Details:

Trying to compile FreeCiv with clang gave me the following error:

console.c:139:15: error: variable length array declaration can not have
'static' storage duration
  static char buf1[(int)trunc(MAX_LEN_CONSOLE_LINE * 1.5)];
  ^~~

trunc() seems completely bogus here.

The fix is simple enough:

$ svn diff
Index: server/console.c
===
--- server/console.c(revision 16001)
+++ server/console.c(working copy)
@@ -136,7 +136,7 @@
 void con_write(enum rfc_status rfc_status, const char *message, ...)
 {
   /* First buffer contains featured text tags */
-  static char buf1[(int)trunc(MAX_LEN_CONSOLE_LINE * 1.5)];
+  static char buf1[(int)(MAX_LEN_CONSOLE_LINE * 1.5)];
   static char buf2[MAX_LEN_CONSOLE_LINE];
   va_list args;
 





___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev