Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix compiling with GCC 4.x versions #16062

Closed
wants to merge 23 commits into from
Closed

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Jan 21, 2025

  • silence false positive picky warnings.
  • avoid "possible noreturn" warnings for standalone tests and examples.
  • fix to compile without #pragma GCC diagnostic push support.
  • fix "#pragma GCC diagnostic not allowed inside functions".

Prerequisite for #15975 that needs GCC 4.4 for the latest pre-built
CeGCC/mingw32ce toolchain for Windows CE.

Cherry-picked from #15975

```
lib/doh.c:285: warning: will never be executed
lib/doh.c:286: warning: will never be executed
lib/doh.c:287: warning: will never be executed
lib/doh.c:288: warning: will never be executed
lib/doh.c:289: warning: will never be executed
lib/doh.c:290: warning: will never be executed
lib/doh.c:291: warning: will never be executed
lib/doh.c:298: warning: will never be executed
lib/doh.c:303: warning: will never be executed
lib/doh.c:304: warning: will never be executed
lib/doh.c:306: warning: will never be executed
lib/doh.c:308: warning: will never be executed
lib/doh.c:310: warning: will never be executed
lib/doh.c:312: warning: will never be executed
lib/doh.c:314: warning: will never be executed
lib/doh.c:316: warning: will never be executed
lib/doh.c:328: warning: will never be executed
lib/doh.c:330: warning: will never be executed
lib/doh.c:334: warning: will never be executed
lib/doh.c:338: warning: will never be executed
lib/doh.c:342: warning: will never be executed
lib/doh.c:346: warning: will never be executed
lib/doh.c:348: warning: will never be executed
lib/doh.c:350: warning: will never be executed
lib/doh.c:352: warning: will never be executed
lib/doh.c:354: warning: will never be executed
lib/doh.c:356: warning: will never be executed
lib/doh.c:375: warning: will never be executed
lib/getinfo.c:242: warning: will never be executed
lib/getinfo.c:245: warning: will never be executed
lib/http.c:1245: warning: will never be executed
lib/http.c:1247: warning: will never be executed
lib/http.c:2359: warning: will never be executed
lib/multi.c:1177: warning: will never be executed
lib/multi.c:2190: warning: will never be executed
lib/multi.c:2193: warning: will never be executed
lib/multi.c:2200: warning: will never be executed
lib/multi.c:2203: warning: will never be executed
lib/multi.c:2208: warning: will never be executed
lib/setopt.c:1287: warning: will never be executed
lib/setopt.c:1294: warning: will never be executed
lib/setopt.c:1301: warning: will never be executed
lib/setopt.c:1336: warning: will never be executed
lib/setopt.c:1669: warning: will never be executed
lib/setopt.c:1676: warning: will never be executed
lib/setopt.c:1686: warning: will never be executed
lib/setopt.c:1695: warning: will never be executed
lib/setopt.c:268: warning: will never be executed
lib/setopt.c:274: warning: will never be executed
lib/setopt.c:275: warning: will never be executed
lib/setopt.c:277: warning: will never be executed
lib/setopt.c:279: warning: will never be executed
lib/setopt.c:290: warning: will never be executed
lib/setopt.c:798: warning: will never be executed
lib/setopt.c:865: warning: will never be executed
lib/setopt.c:881: warning: will never be executed
lib/setopt.c:956: warning: will never be executed
lib/setopt.c:979: warning: will never be executed
lib/setopt.c:991: warning: will never be executed
lib/strtoofft.c:235: warning: will never be executed
lib/urlapi.c:627: warning: will never be executed
src/tool_cb_dbg.c:109: warning: will never be executed
src/tool_cb_dbg.c:110: warning: will never be executed
src/tool_cb_hdr.c:132: warning: will never be executed
src/tool_cb_hdr.c:136: warning: will never be executed
src/tool_cb_rea.c:95: warning: will never be executed
src/tool_cb_wrt.c:93: warning: will never be executed
src/tool_dirhie.c:51: warning: will never be executed
src/tool_dirhie.c:56: warning: will never be executed
src/tool_dirhie.c:66: warning: will never be executed
src/tool_dirhie.c:72: warning: will never be executed
src/tool_getpass.c:161: warning: will never be executed
src/tool_getpass.c:172: warning: will never be executed
src/tool_help.c:397: warning: will never be executed
src/tool_main.c:268: warning: will never be executed
src/tool_operate.c:2285: warning: will never be executed
src/tool_operate.c:2419: warning: will never be executed
src/tool_operate.c:2421: warning: will never be executed
src/tool_operate.c:2422: warning: will never be executed
src/tool_operate.c:2423: warning: will never be executed
src/tool_operate.c:2424: warning: will never be executed
src/tool_operate.c:2450: warning: will never be executed
src/tool_operate.c:2716: warning: will never be executed
src/tool_operate.c:2965: warning: will never be executed
src/tool_operate.c:489: warning: will never be executed
src/tool_operate.c:513: warning: will never be executed
src/tool_operate.c:559: warning: will never be executed
src/tool_operate.c:570: warning: will never be executed
src/tool_operate.c:574: warning: will never be executed
src/tool_operate.c:601: warning: will never be executed
src/tool_operate.c:602: warning: will never be executed
src/tool_operate.c:631: warning: will never be executed
src/tool_operate.c:738: warning: will never be executed
src/tool_operate.c:887: warning: will never be executed
src/tool_operate.c:897: warning: will never be executed
src/tool_paramhlp.c:236: warning: will never be executed
src/tool_paramhlp.c:325: warning: will never be executed
src/tool_setopt.c:276: warning: will never be executed
src/tool_setopt.c:314: warning: will never be executed
src/tool_setopt.c:359: warning: will never be executed
src/tool_setopt.c:567: warning: will never be executed
src/tool_setopt.c:589: warning: will never be executed
src/tool_setopt.c:634: warning: will never be executed
src/tool_setopt.c:663: warning: will never be executed
src/tool_setopt.c:672: warning: will never be executed
src/tool_setopt.c:689: warning: will never be executed
src/tool_ssls.c:50: warning: will never be executed
src/tool_urlglob.c:291: warning: will never be executed
src/tool_urlglob.c:298: warning: will never be executed
src/tool_writeout.c:168: warning: will never be executed
src/tool_writeout.c:204: warning: will never be executed
src/tool_writeout.c:278: warning: will never be executed
src/tool_writeout.c:298: warning: will never be executed
src/tool_writeout.c:311: warning: will never be executed
src/tool_writeout.c:444: warning: will never be executed
src/tool_writeout.c:508: warning: will never be executed
```
(with each lines repeating many times)
```
src/tool_writeout.c: In function 'ourWriteOut':
src/tool_writeout.c:567: warning: missing initializer
src/tool_writeout.c:567: warning: (near initialization for 'find.id')
```
```
lib/doh.c: In function 'doh_strerror':
lib/doh.c:72: warning: comparison of unsigned expression >= 0 is always true
```
```
tests/unit/unit3200.c:71: error: string length '4102' is greater than the length '509' ISO C90 compilers are required to support
tests/unit/unit3200.c:75: error: string length '4117' is greater than the length '509' ISO C90 compilers are required to support
tests/unit/unit3200.c:80: error: string length '4124' is greater than the length '509' ISO C90 compilers are required to support
```
https://github.com/curl/curl/actions/runs/12739275569/job/35502739643#step:11:27
We can't use CURL_NORETURN in standalone programs, so convert the
function to a macro to avoid the warning.

```
/Users/runner/work/curl/curl/tests/http/clients/h2-pausing.c: In function 'err':
/Users/runner/work/curl/curl/tests/http/clients/h2-pausing.c:143: error: function might be possible candidate for attribute 'noreturn'
```
https://github.com/curl/curl/actions/runs/12740010529/job/35504589682#step:11:32
https://stackoverflow.com/questions/1538943/why-is-the-compiler-throwing-this-warning-missing-initializer-isnt-the-stru#
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750

```
src/tool_writeout.c: In function 'ourWriteOut':
src/tool_writeout.c:567: warning: missing initializer
src/tool_writeout.c:567: warning: (near initialization for 'find.id')
```

```
tests/server/sws.c: In function 'get_request':
tests/server/sws.c:905: warning: missing initializer
tests/server/sws.c:905: warning: (near initialization for 'timeout.tv_usec')
tests/server/sws.c: In function 'connect_to':
tests/server/sws.c:1384: warning: missing initializer
tests/server/sws.c:1384: warning: (near initialization for 'timeout.tv_usec')
tests/server/sws.c: In function 'http_connect':
tests/server/sws.c:1507: warning: missing initializer
tests/server/sws.c:1507: warning: (near initialization for 'timeout.tv_usec')
tests/server/sws.c: In function 'main':
tests/server/sws.c:2378: warning: missing initializer
tests/server/sws.c:2378: warning: (near initialization for 'timeout.tv_usec')
tests/libtest/lib530.c: In function 'testone':
tests/libtest/lib530.c:272: warning: missing initializer
tests/libtest/lib530.c:272: warning: (near initialization for 'timeout.tv_usec')
tests/libtest/lib530.c:314: warning: missing initializer
tests/libtest/lib530.c:314: warning: (near initialization for 'tv.tv_usec')
tests/libtest/lib582.c: In function 'test_lib582':
tests/libtest/lib582.c:238: warning: missing initializer
tests/libtest/lib582.c:238: warning: (near initialization for 'timeout.tv_usec')
tests/libtest/lib582.c:314: warning: missing initializer
tests/libtest/lib582.c:314: warning: (near initialization for 'tv.tv_usec')
tests/libtest/lib678.c: In function 'test_lib678':
tests/libtest/lib678.c:107: warning: missing initializer
tests/libtest/lib678.c:107: warning: (near initialization for 'blob.len')
```
```
/Users/runner/work/curl/curl/tests/unit/unit1398.c:27: error: expected [error|warning|ignored] after '#pragma GCC diagnostic'
/Users/runner/work/curl/curl/tests/unit/unit1398.c:190: error: expected [error|warning|ignored] after '#pragma GCC diagnostic'
```
https://github.com/curl/curl/actions/runs/12736021108/job/35495445165#step:11:23
This reverts commit 4c551e62ad12557b74cbd8019aaae34e100688a1.
gcc <4.6 does not support gcc diagnostic push/pop, but
in example we also don't need to do this. They are standalone
apps. (when copied elsewhere as-is it needs to be taken care
of manually)
To avoid this with gcc 4.4.0:
```
docs/examples/sendrecv.c: In function 'wait_on_socket':
docs/examples/sendrecv.c:57: error: #pragma GCC diagnostic not allowed inside functions
```
It was fixed by gcc 4.8.1. As tested via godbolt.org.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant