bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error: Support the compiler's control flow analysis better (was: cop


From: Paul Eggert
Subject: Re: error: Support the compiler's control flow analysis better (was: copy-file: Silence gcc warnings)
Date: Tue, 30 May 2023 14:47:26 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

On 5/27/23 13:53, Bruno Haible wrote:
+#  define error(status, ...) \
+     ((error)(0, __VA_ARGS__), (status) ? exit (status) : (void)0)

We can do a bit better than that by using 'unreachable ()' instead of 'exit (status)', and passing 'status' (instead of 0) to the underlying error function. This saves a function call and should still pacify GCC.

Also, it's better to not evaluate 'status' twice. Not that I think 'status' should have side effects or even that it does have side effects in any Gnulib-using code, just that it's more hygienic in case some caller foolishly puts side effects there.

I installed the attached further patches into Gnulib to try to address these issues.

Attachment: 0001-error-don-t-evaluate-status-arg-twice.patch
Description: Text Data

Attachment: 0002-error-don-t-call-exit.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]