Menu

What is the recommended method to suppress superfluous warning messages.

Anonymous
2022-09-10
2022-09-16
  • Anonymous

    Anonymous - 2022-09-10

    What's the recommended method in GnuCOBOL to suppress certain superfluous warning messages? An example is if I have a call statement like:

    CALL "SUB" USING PARM,
                                                  DUMMY,
                                                  DUMMY,
                                                  DUMMY.
    

    it gets flagged with warnings like "warning: duplicate USING BY REFERENCE item 'DUMMY' [-Wothers]" even though I've used that with many other COBOL compilers over the years. It doesn't seem to have an effect on the compiled code. I'm just a bit picky about getting warnings for what's otherwise valid code.

    Thanks in advance.

     
  • Simon Sobisch

    Simon Sobisch - 2022-09-10

    What's the recommended method in GnuCOBOL to suppress certain superfluous warning messages?

    Intro: each warning has an option, with a "recent" version (not older than 2021) it is shown in the message - in your case [-Wother] the option name is other.
    The two options "other" and "additional" are special cases as they group a bunch of different issues where there wasn't seen a reason (yet) to use a separate option; check NEWS when changing the version, it will tell about adjusted warning options (new and split warning options and in theory dropped ones, which did not happen so far).

    1. understand what the message is about and why it is there; cobc --help or the manual - which contains its output formatted - have a description, a search with the option name in this discussion board or on the net often helps, too
    2. check if it is a good idea to ignore it (for example things like missing terminators are likely be seen as style issue); the default warnings are a reasonable subset, ignoring these should be an educated decision; the subset of -Wall are still things to consider twice, -Wextra (or previous -W) is mostly useful if you inspect programs with strange results; and in any case you may even find that for your style/house rules you want to increase a specific warning to an error with -Werror=option
    3. handle the message:
      1. fix the actual code, either manual or with conversion program (commonly even a sed is enough)
      2. disable by name, so in this case -Wno-other
      3. in your post-compile / warning check procedures drop/ignore that warning (this may be quite specific, like in your case only doing so if it contains "DUMMY")
      4. change cobc to not raise this specific warning at all

    For this specific message, which we just discussed in [64b12f8a19]:

    PROCEDURE DIVISION USING VAR-1, VAR-2, VAR-2, VAR-2 - same variable in a called program on more than one place - is explicit forbidden. Doing a CALL PROG USING PARM, DUMMY, DUMMY, DUMMY is effectively doing that from the caller.
    COBOL has the language feature to specify OMITTED for a parameter which is not to be passed, this solves most of the issues (of course the called program should then not use this parameter other than a potential IF PARM-2 IS [NOT] OMITTED).

    ... if you still want to disable it, as mentioned in 3.2: compile with -Wno-other (but as mentioned in the intro "other" groups a bunch of warnings, you may want to check in the compiler's sources of your specific version for COBC_WARN_FILLER to see what it is used for, before disabling all of these).

     

    Related

    Discussion: 64b12f8a19

  • Brian Tiffin

    Brian Tiffin - 2022-09-16

    It's relatively dangerous, as it's so easy to over use, but if you know know that all the warnings you're seeing are superfluous to the current round of edit compile link go repeat iterations, and for completeness, cobc -w. little w. No warnings. None. Only recommended for short bursts or programming in the small or experimental. -Wall and fixes being the better way for work COBOL. ;-)

    In the case at hand, it's a warning you'd usually want to see when passing addresses of writable fields ... but -w comes in handy at times.

    Cheers,
    Blue

     

Anonymous
Anonymous

Add attachments
Cancel