9567 make: error: control reaches end of non-void function

Review Request #1095 - Created May 31, 2018 and updated

Toomas Soome
/code/illumos-gate/usr/src/cmd/make/bin/ar.cc: In function 'Boolean read_archive_dir(Ar*, Name, char**)':
    /code/illumos-gate/usr/src/cmd/make/bin/ar.cc:546:1: error: control reaches end of non-void function [-Werror=return-type]

    /code/illumos-gate/usr/src/cmd/make/bin/doname.cc: In function 'Doname doname_check(Name, Boolean, Boolean, Boolean)':
    /code/illumos-gate/usr/src/cmd/make/bin/doname.cc:181:1: error: control reaches end of non-void function [-Werror=return-type]
    cc1plus: all warnings being treated as errors

Toomas Soome
Review request changed

Change Summary:

cstyle cleanup.




Revision 2 (+141 -106)

Show changes

Yuri Pankov

I don't see why gcc said about reaching the end -- won't marking fatal as __NORETURN be enough here? Or are there some values we don't handle in the switch?

  1. Yes, thats the reason why I wrote the note into the issue - it certainly does seem like compiler bug on diagnostics. However, I really would also like to get rid of that lint workaround which is just as confusing.

    TBH, I would like to see explicit return statement at the end of the function and not being enforced to track every single switch case to see if they have really covered all cases.

  2. Yep, that code is interesting, especially the register stuff - does it make any sense today?

  3. no, it is not an error to have the register specifier, but it is silently ignored.

  4. yeah, that's what I mean, it's not an error, but doesn't have any effect as well (code being ancient).

Yuri Pankov
Ship It!
Gary Mills

In the case of doname.cc, the compiler likely complains because there's no default case in the switch. Your change does fix the problem.

Is there an easy way you can verify that `make' still behaves the same?

Ken Mays
Ship It!