|
|
Log in / Subscribe / Register

LLVM 2.9 released

LLVM 2.9 released

Posted Apr 11, 2011 17:01 UTC (Mon) by wahern (subscriber, #37304)
In reply to: LLVM 2.9 released by mpr22
Parent article: LLVM 2.9 released

`if (foo = bar) { ... }' isn't broken. In fact `if (foo = bar || 1) { ... }' isn't broken either, just very uncommon.

But I also disagree that -Werror shouldn't be used. I use it all the time. And when it breaks my code, rather than concede defeat I submit a patch. I submitted a patch to clang which added a switch to disable duplicate initializer warnings (like GCC has). It's valid and useful code and the C99 standard even specifies the behavior--the last initializer wins. I use it with compound literals and named initializers when I want an inline automatic object with default initializations:

struct options { int foo; int bar; };
#define FOO_DEFAULT 7
#define opts(...) (&(struct options){ .foo = FOO_DEFAULT, __VA_ARGS__ })

do_blah(blah, opts(.foo = 14, .bar = 12))

It took me a couple of days to learn enough about clang to be able to submit the patch, but that's what the community is all about--scratching our own itches. It's a privilege but also a responsibility.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds