BUG #16823: Unreachable code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG #16823: Unreachable code

PG Bug reporting form
The following bug has been logged on the website:

Bug reference:      16823
Logged by:          Rupert
Email address:      [hidden email]
PostgreSQL version: 13.1
Operating system:   openbsd
Description:        

localtime.c:135:40: warning: code will never be executed
[-Wunreachable-code]
                result -= !TWOS_COMPLEMENT(int32) && result != 0;
                                                     ^~~~~~
localtime.c:161:40: warning: code will never be executed
[-Wunreachable-code]
                result -= !TWOS_COMPLEMENT(int64) && result != 0;
                                                     ^~~~~~
localtime.c:299:52: warning: code will never be executed
[-Wunreachable-code]
                                = ((TYPE_SIGNED(pg_time_t) ? at < TIME_T_MIN
: at < 0)
                                                                           
  ^~
localtime.c:1564:58: warning: code will never be executed
[-Wunreachable-code]
                  ? (TYPE_SIGNED(pg_time_t) ? TIME_T_MIN - j <= *tp : -1 - j
< *tp)
                                                                       ^
4 warnings generated.
bootparse.c:2132:14: warning: code will never be executed
[-Wunreachable-code]
  yyresult = 2;
             ^
1 warning generated.
bootstrap.c:465:4: warning: code will never be executed
[-Wunreachable-code]
                        proc_exit(1);           /* should never return */
                        ^~~~~~~~~
bootstrap.c:460:4: warning: code will never be executed
[-Wunreachable-code]
                        proc_exit(1);           /* should never return */
                        ^~~~~~~~~
bootstrap.c:454:4: warning: code will never be executed
[-Wunreachable-code]
                        proc_exit(1);           /* should never return */
                        ^~~~~~~~~
bootstrap.c:449:4: warning: code will never be executed
[-Wunreachable-code]
                        proc_exit(1);           /* should never return */
                        ^~~~~~~~~
bootstrap.c:444:4: warning: code will never be executed
[-Wunreachable-code]
                        proc_exit(1);           /* should never return */
                        ^~~~~~~~~
5 warnings generated.
main.c:211:2: warning: code will never be executed [-Wunreachable-code]
        abort();                                        /* should not get
here */
        ^~~~~
1 warning generated.
heapam.c:5364:11: warning: code will never be executed
[-Wunreachable-code]
        result = TM_Ok;
                 ^~~~~
1 warning generated.
postmaster.c:1419:2: warning: code will never be executed
[-Wunreachable-code]
        abort();                                        /* not reached */
        ^~~~~
postmaster.c:5513:3: warning: code will never be executed
[-Wunreachable-code]
                ExitPostmaster(0);
                ^~~~~~~~~~~~~~
postmaster.c:5892:4: warning: code will never be executed
[-Wunreachable-code]
                        exit(1);                        /* should not get
here */
                        ^~~~
3 warnings generated.
repl_gram.c:1942:14: warning: code will never be executed
[-Wunreachable-code]
  yyresult = 2;
             ^
1 warning generated.
scan.c:6678:13: warning: code will never be executed [-Wunreachable-code]
                                        if ( !
yyg->yy_did_buffer_switch_on_eof )
                                               ^~~
walsender.c:368:2: warning: code will never be executed
[-Wunreachable-code]
        abort();                                        /* keep the compiler
quiet */
        ^~~~~
1 warning generated.
1 warning generated.
ri_triggers.c:1554:3: warning: code will never be executed
[-Wunreachable-code]
                ExecDropSingleTupleTableSlot(slot);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
fe-connect.c:1112:16: warning: code will never be executed
[-Wunreachable-code]
                                ch->host = strdup(DefaultHost);
                                           ^~~~~~
1 warning generated.
pgc.c:3825:14: warning: code will never be executed [-Wunreachable-code]
                                        if ( ! (yy_did_buffer_switch_on_eof)
)
                                               
^~~~~~~~~~~~~~~~~~~~~~~~~~~
variable.c:472:4: warning: code will never be executed
[-Wunreachable-code]
                        struct ECPGstruct_member *p;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
data.c:372:6: warning: code will never be executed [-Wunreachable-code]
                                        long            res;
                                        ^~~~~~~~~~~~~~~~~~~~
execute.c:567:5: warning: code will never be executed [-Wunreachable-code]
                                int                     element;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
1 warning generated.
1 warning generated.
psqlscan.c:3387:13: warning: code will never be executed
[-Wunreachable-code]
                                        if ( !
yyg->yy_did_buffer_switch_on_eof )
                                               ^~~
1 warning generated.
localtime.c:135:40: warning: code will never be executed
[-Wunreachable-code]
                result -= !TWOS_COMPLEMENT(int32) && result != 0;
                                                     ^~~~~~
localtime.c:161:40: warning: code will never be executed
[-Wunreachable-code]
                result -= !TWOS_COMPLEMENT(int64) && result != 0;
                                                     ^~~~~~
localtime.c:299:52: warning: code will never be executed
[-Wunreachable-code]
                                = ((TYPE_SIGNED(pg_time_t) ? at < TIME_T_MIN
: at < 0)
                                                                           
  ^~
localtime.c:1564:58: warning: code will never be executed
[-Wunreachable-code]
                  ? (TYPE_SIGNED(pg_time_t) ? TIME_T_MIN - j <= *tp : -1 - j
< *tp)
                                                                       ^
4 warnings generated.
file.c:355:2: warning: code will never be executed [-Wunreachable-code]
        unlink(new_link_file);
        ^~~~~~
1 warning generated.
exprparse.c:1869:14: warning: code will never be executed
[-Wunreachable-code]
  yyresult = 2;
             ^
1 warning generated.
psqlscanslash.c:2105:13: warning: code will never be executed
[-Wunreachable-code]
                                        if ( !
yyg->yy_did_buffer_switch_on_eof )
                                               ^~~
1 warning generated.
pl_gram.c:4924:14: warning: code will never be executed
[-Wunreachable-code]
  yyresult = 2;
             ^
1 warning generated.

Reply | Threaded
Open this post in threaded view
|

Re: BUG #16823: Unreachable code

Tom Lane-2
PG Bug reporting form <[hidden email]> writes:
> localtime.c:135:40: warning: code will never be executed
> [-Wunreachable-code]
>                 result -= !TWOS_COMPLEMENT(int32) && result != 0;
>                                                      ^~~~~~

[ and much more in the same vein ]

We're unlikely to change any of these, so I'd recommend turning off
-Wunreachable-code.

localtime.c is a clone of the IANA timezone code, so we're certainly
not going to change it unless they do (which I doubt they would).
bootparse.c, and some of the other files you mention, are code generated
by bison, which we have no control over.  Most of the rest of these
are already manually commented as being unreachable; they're there
partly for belt-and-suspenders reasons, and partly because some other
compilers will warn if we don't have them.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: BUG #16823: Unreachable code

Rupert Gallagher
Turning off the warning will not make the code reachable. Non reachable means that it will never be executed. If you are sure that it is ok to never execute it, then remove it.


-------- Original Message --------
On Jan 13, 2021, 17:42, Tom Lane < [hidden email]> wrote:
PG Bug reporting form <[hidden email]> writes:
> localtime.c:135:40: warning: code will never be executed
> [-Wunreachable-code]
> result -= !TWOS_COMPLEMENT(int32) && result != 0;
> ^~~~~~
[ and much more in the same vein ]
We're unlikely to change any of these, so I'd recommend turning off
-Wunreachable-code.
localtime.c is a clone of the IANA timezone code, so we're certainly
not going to change it unless they do (which I doubt they would).
bootparse.c, and some of the other files you mention, are code generated
by bison, which we have no control over. Most of the rest of these
are already manually commented as being unreachable; they're there
partly for belt-and-suspenders reasons, and partly because some other
compilers will warn if we don't have them.
regards, tom lane