Bug #48331 msys/my_sync.c uses C99 Syntax - breaks GCC 2.95
Submitted: 26 Oct 2009 21:47 Modified: 12 Mar 2010 15:41
Reporter: Todd Rinaldo Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.1.40 OS:Linux (GCC 2.95)
Assigned to: CPU Architecture:Any
Tags: Contribution

[26 Oct 2009 21:47] Todd Rinaldo
Description:
Hi, the function my_sync_dir inside mysys/my_sync.c breaks under older GCC compiler. The reason is that it puts DBUG_ENTER and DBUG_PRINT macros at the top of the function and then declares variables afterwards. The 2 macros expand to call functions so this is not allowed. Simply moving the macro calls below the variable declarations fixes the problem.

How to repeat:
compile code on a GCC 2.95 compiler 

Suggested fix:
Apply this patch to the code, moving the variable declarations to the top of the function.

diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index ba6964b..97540f5 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -103,11 +103,11 @@ static const char cur_dir_name[]= {FN_CURLIB, 0};
 int my_sync_dir(const char *dir_name, myf my_flags)
 {
 #ifdef NEED_EXPLICIT_SYNC_DIR
-  DBUG_ENTER("my_sync_dir");
-  DBUG_PRINT("my",("Dir: '%s'  my_flags: %d", dir_name, my_flags));
   File dir_fd;
   int res= 0;
   const char *correct_dir_name;
+  DBUG_ENTER("my_sync_dir");
+  DBUG_PRINT("my",("Dir: '%s'  my_flags: %d", dir_name, my_flags));
   /* Sometimes the path does not contain an explicit directory */
   correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name;
   /*
[27 Oct 2009 11:11] Valeriy Kravchuk
Thank you for the problem report and patch contributed. As http://dev.mysql.com/doc/refman/5.1/en/installing-source.html still mentions that gcc 2.95.2 and newer can be used for building, I agree that this is a bug.

Maybe we should instead just explicitly document that gcc 4.x.y is required...
[2 Dec 2009 8:08] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:kent.boortz@sun.com-20091125154829-i8k4040a9w0mp0ue) (merge vers: 5.1.42) (pib:13)
[11 Dec 2009 19:58] Paul DuBois
No changelog entry needed.
[16 Dec 2009 8:41] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:48] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:alexey.kopytov@sun.com-20091201145844-39gy4wmejbisbxac) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:55] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[17 Dec 2009 10:56] MC Brown
No changelog entry needed.
[12 Mar 2010 14:21] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:35] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:36] MC Brown
No changelog entry needed.
[12 Mar 2010 14:51] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[12 Mar 2010 15:41] MC Brown
No changelog entry needed.