bugGNU troff - Bugs: bug #54702, [PATCH] hdb.cpp: Add information...

 
 

bug #54702: [PATCH] hdb.cpp: Add information for the compiler to avoid lack of clarity

Submitted by:  Bjarni Ingi Gislason <bjarniig>
Submitted on:  Thu 20 Sep 2018 11:41:10 PM UTC  
 
Category:  Preprocessor grn Severity:  2 - Minor
Item Group:  Warning/Suspicious behaviour Status:  Confirmed
Privacy:  Public Assigned to:  Bertrand Garrigues <bgarrigues>
Open/Closed:  Open Planned Release:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 04 Nov 2018 05:55:44 PM UTC, comment #3: 

I used this (Makefile):

CC = /usr/bin/gcc

CFLAGS = -Wall -Wextra -Wformat=2 -Wmissing-prototypes
-Wmissing-declarations -Wold-style-definition -Wstrict-prototypes
-fstack-protector-strong -fno-common -funsigned-char
-fvar-tracking-assignments -O0 -std=c11 -pedantic

CXXFLAGS = -Wall -Wextra -Wformat=2  -fstack-protector-strong
-fno-common -funsigned-char  -O0 -fvar-tracking-assignments

Bjarni Ingi Gislason <bjarniig>
Sun 04 Nov 2018 09:36:47 AM UTC, comment #2: 

I don't see any such warnings on my Debian testing system:

$ gcc --version
gcc (Debian 8.2.0-8) 8.2.0
[...]

  CC       src/utils/xtotroff/xtotroff-xtotroff.o
  CXX      src/preproc/eqn/eqn-main.o
  CXX      src/preproc/grn/hdb.o
  CXX      src/preproc/grn/hpoint.o
  CXX      src/preproc/grn/hgraph.o
  CXX      src/preproc/grn/main.o
  CXX      src/preproc/pic/pic-pic.o

How are you driving the build?

G. Branden Robinson <gbranden>
Project Administrator
Fri 21 Sep 2018 12:36:14 AM UTC, comment #1: 

I forgot to add <minus>verbatim<minus> at the end of the original comment.
  Correct the patch as I forgot to add a semicolon after the "return (0)".

From 7403a7a85f4e5fb15b4fc3a039c7f7963570e0f9 Mon Sep 17 00:00:00 2001
From: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Date: Fri, 21 Sep 2018 00:05:35 +0000
Subject: [PATCH] hdb.cpp: Add information for the compiler to avoid lack of
clarity

  A question from the compiler (gcc 8.2) (example):

../src/preproc/grn/hdb.cpp:260:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
       fatal("unknown element type");

  Add an explicit "return", so that the compiler knows that there is no
possibility of a "fallthrough".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
src/preproc/grn/hdb.cpp | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/preproc/grn/hdb.cpp b/src/preproc/grn/hdb.cpp
index fe722c6a..f2463f3c 100644
--- a/src/preproc/grn/hdb.cpp
+++ b/src/preproc/grn/hdb.cpp
@@ -246,6 +246,7 @@ DBGetType(register char *s)
     default:
       fatal("unknown element type");
       // fatal() does not return
+      return (0); // avoid a warning about possible fallthrough
     }
   case 'B':
     switch (s[3]) {
@@ -258,6 +259,7 @@ DBGetType(register char *s)
     default:
       fatal("unknown element type");
       // fatal() does not return
+      return (0); // avoid a warning about a possible fallthrough
     }
   case 'T':
     switch (s[3]) {
@@ -270,6 +272,7 @@ DBGetType(register char *s)
     default:
       fatal("unknown element type");
       // fatal() does not return
+      return (0); // avoid a warning about a possible fallthrough
     }
   default:
     fatal("unknown element type");
--
2.18.0

Bjarni Ingi Gislason <bjarniig>
Thu 20 Sep 2018 11:41:10 PM UTC, original submission:  
Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bgarrigues (Updated the item)
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-26 bgarrigues Severity3 - Normal => 2 - Minor
        Item GroupBuild/Installation => Warning/Suspicious behaviour
        StatusNeed Info => Confirmed
        Assigned toNone => bgarrigues
    2018-11-04 gbranden Item GroupNone => Build/Installation
        StatusNone => Need Info

    Back to the top


    Powered by Savane 3.5