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

Vala C code started printing warnings on 1.4.0 #13023

Closed
GeopJr opened this issue Mar 30, 2024 · 4 comments
Closed

Vala C code started printing warnings on 1.4.0 #13023

GeopJr opened this issue Mar 30, 2024 · 4 comments

Comments

@GeopJr
Copy link

GeopJr commented Mar 30, 2024

Describe the bug
After updating to 1.4.0, compiling Vala projects prints C warnings, specifically:

  • Wunused-value
  • Wsign-compare
  • Wunused-parameter
  • Wunused-but-set-variable
  • Wduplicate-decl-specifier
  • Wunused-variable
  • Wunused-value
  • Wunused-function

To Reproduce

project(
    'dev.geopjr.MesonTest',
    ['c', 'vala'],
    version: '0.0.1',
    meson_version: '>= 0.56.0',
    default_options: [
        'warning_level=2',
        'werror=false',
    ],
)

dependencies = [
    dependency('glib-2.0'),
    dependency('gobject-2.0'),
]

sources = files('test.vala')

executable('MesonTest', sources, dependencies: dependencies)
public class Test : GLib.Object {}
void main () {}

will output

[2/3] Compiling C object MesonTest.p/meson-generated_test.c.o
test.c:79:27: warning: unused parameter 'klass_data' [-Wunused-parameter]
   79 |                  gpointer klass_data)
      |                           ^
test.c:87:28: warning: unused parameter 'self' [-Wunused-parameter]
   87 | test_instance_init (Test * self,
      |                            ^
test.c:88:30: warning: unused parameter 'klass' [-Wunused-parameter]
   88 |                     gpointer klass)
      |                              ^
test.c:119:11: warning: unused parameter 'argc' [-Wunused-parameter]
  119 | main (int argc,
      |           ^
test.c:120:15: warning: unused parameter 'argv' [-Wunused-parameter]
  120 |       char ** argv)
      |               ^
MesonTest.p/test.c:38:20: warning: unused variable 'test_properties' [-Wunused-variable]
   38 | static GParamSpec* test_properties[TEST_NUM_PROPERTIES];
      |                    ^~~~~~~~~~~~~~~
6 warnings generated.
[3/3] Linking target MesonTest

Expected behavior
No C warnings should be printed, just like it did prior to 1.4.0

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? - native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) - Chimera Linux
  • what Python version are you using e.g. 3.8.0 - 3.12.2
  • what meson --version - 1.4.0
  • what ninja --version if it's a Ninja build - 1.11.1
@GeopJr
Copy link
Author

GeopJr commented Mar 30, 2024

@eli-schwartz
Copy link
Member

It intentionally does so due to #12597.

Quoting myself from there:

Compiler warnings are NOT safe to just... universally turn off. Compiler warnings could be either:

  • coding style lints

  • threatening statements that the code is factually and behaviorally wrong

There is no magic bullet to ignore the former while respecting the latter. And the very last thing we should ever do is pass -w, since that causes ALL warnings to be disabled, even the manually added -Werror=XXX.

Unfortunately, disabling all warnings is a security vulnerability. Meson has stopped doing it. That being said, it's still possible to specify the warnings you'd like to disable with -Wno-*.

Unused in particular seems like something that code generators which optimistically generate lots of code that may never get used, could disable via a pragma in code generation. In theory, meson could "just" turn those off instead of the previous -w. In practice I'm hesitant to get into the business of picking and choosing which warnings a code generator should ignore, as that's how we ended up ignoring warnings that flag dangerous UB.

I should also note that not all code generators are equal; this is fixable by vala and it was overreach for meson to disable all warnings for e.g. cython too.

@eli-schwartz eli-schwartz closed this as not planned Won't fix, can't repro, duplicate, stale Mar 31, 2024
@GeopJr
Copy link
Author

GeopJr commented Mar 31, 2024

I see, thanks for the info!

@rilian-la-te
Copy link
Contributor

rilian-la-te commented Mar 31, 2024

How to disable some C warnings for only Vala-generated code? Is such way exists? Or only hackish one like "split Vala code to static library, and then pass compiler flags to it"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants