Bug #57933 add -Wdeclaration-after-statement to gcc builds

Submitted: 2 Nov 2010 17:09 Modified: 20 Nov 2010 18:12
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:5.1, 5.5 OS:Any
Assigned to: CPU Architecture:Any

[2 Nov 2010 17:09] Guilhem Bichot
Description:
gcc is very permissive: on my Linux I accidentally inserted this type of code into a .c file:

void func()
{
  int x;
  x=  3;
  int y;
}
It built without error, I pushed, but it broke on some pushbuild2 machine (Windows), because of course in C (prior to C99) you cannot have a declaration after a statement.
I propose to add -Wdeclaration-after-statement to our default CFLAGS for gcc builds.
This way I wouldn't have pushed this mistake.

How to repeat:
see description.
[3 Nov 2010 14:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122716

3552 Guilhem Bichot	2010-11-03
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds";
      first part, for autotools build.
     @ config/ac-macros/maintainer.m4
        Add the flag. With it, and as we use -Werror, we nicely get
        "error: ISO C90 forbids mixed declarations and code" if
        a declaration follows a statement in C code.
        Note that g++ refuses this flag.
[3 Nov 2010 16:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122736

3122 Guilhem Bichot	2010-11-03
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
      implementation for autotools and cmake.
     @ CMakeLists.txt
        Detect compiler flag -Wdeclaration-after-statement and use it if exists.
        The detection cannot happen before "INCLUDE(configure.cmake)" because
        configure.cmake is what does
        "INCLUDE (CheckCSourceCompiles)"
        which is needed for CHECK_C_COMPILER_FLAG.
        That's a first reason to move the first maintainer-related block down.
        A second reason is that I could not understand why we set some
        variables (MY_MAINTAINER*) early in a first block; I believe they don't influence
        anything until we use them to set CMAKE_C_FLAGS in the second block.
        So I move the first block into the second.
        I don't know whether adding -Wno-error to CMAKE_REQUIRED_FLAGS
        is still needed, for me it compiles even without it, but I
        left it.
     @ config/ac-macros/maintainer.m4
        Add flag to autotools build.
[3 Nov 2010 16:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122737

3122 Guilhem Bichot	2010-11-03
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
      implementation for autotools and cmake.
     @ CMakeLists.txt
        Detect compiler flag -Wdeclaration-after-statement and use it if exists.
        The detection cannot happen before "INCLUDE(configure.cmake)" because
        configure.cmake is what does
        "INCLUDE (CheckCSourceCompiles)"
        which is needed for CHECK_C_COMPILER_FLAG.
        That's a first reason to move the first maintainer-related block down.
        A second reason is that I could not understand why we set some
        variables (MY_MAINTAINER*) early in a first block; I believe they don't influence
        anything until we use them to set CMAKE_C_FLAGS in the second block.
        So I move the first block into the second.
        I don't know whether adding -Wno-error to CMAKE_REQUIRED_FLAGS
        is still needed, for me it compiles even without it, but I
        left it.
     @ config/ac-macros/maintainer.m4
        Add flag to autotools build.
[4 Nov 2010 18:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122869

3122 Guilhem Bichot	2010-11-04
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
      implementation for autotools and cmake.
     @ CMakeLists.txt
        Detect compiler flag -Wdeclaration-after-statement and use it if exists.
        The detection cannot happen before "INCLUDE(configure.cmake)" because
        configure.cmake is what does
        "INCLUDE (CheckCSourceCompiles)"
        which is needed for CHECK_C_COMPILER_FLAG.
        That's a first reason to move the first maintainer-related block down.
        A second reason is that I could not understand why we set some
        variables (MY_MAINTAINER*) early in a first block; I believe they don't influence
        anything until we use them to set CMAKE_C_FLAGS in the second block.
        So I move the first block into the second.
        I don't know whether adding -Wno-error to CMAKE_REQUIRED_FLAGS
        is still needed, for me it compiles even without it, but I
        left it.
     @ config/ac-macros/maintainer.m4
        Add flag to autotools build.
[5 Nov 2010 9:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122911

3122 Guilhem Bichot	2010-11-05
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
      implementation for autotools and cmake.
     @ CMakeLists.txt
        Detect compiler flag -Wdeclaration-after-statement and use it if exists.
     @ config/ac-macros/maintainer.m4
        Add flag to autotools build.
[5 Nov 2010 13:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122949

3553 Guilhem Bichot	2010-11-05
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds";
      first part, for autotools build.
     @ config/ac-macros/maintainer.m4
        Add the flag. With it, and as we use -Werror, we nicely get
        "error: ISO C90 forbids mixed declarations and code" if
        a declaration follows a statement in C code.
        Note that g++ refuses this flag.
[5 Nov 2010 13:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122953

3124 Guilhem Bichot	2010-11-05 [merge]
      Merge of the fix for BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
      from 5.1; extended here to Cmake builds.
[5 Nov 2010 14:12] Guilhem Bichot
queued to 5.1-bugteam, 5.5-bugteam, trunk-bugfixing.
It's about compiler flags used by us, no changelog needed.
[13 Nov 2010 16:05] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:30] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[20 Nov 2010 18:12] Paul DuBois
No changelog entry needed.
[15 Dec 2010 5:53] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:sunanda.menon@oracle.com-20101215054055-vgwki317xg1wphhh) (version source revid:sunanda.menon@oracle.com-20101215054055-vgwki317xg1wphhh) (merge vers: 5.1.55) (pib:23)
[16 Dec 2010 22:26] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.074 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.