Building pidgin-sipe on FreeBSD-10.1, where clang-3.4.1 is the default compiler, I had to fix the following problem:
sipe-ews-autodiscover.c:313:42: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier]
static const struct autodiscover_method const methods[] = {
^
1 error generated.
That said, I find it commendable, that pidgin-sipe project aims to deliver warning-free code. Thank you!
It's a const array of const structures. I don't see anything wrong with that code.
Closing as WONTFIX.
I think, the difference is in using the array notation ([]) rather than pointer (*). With array, the second const is redundant, because the entire contents of the array is already const.
In C++ either both the array and its elements are const or neither are const. (See 8.3.4p1 [dcl.array] of the C++11 standard) Therefore the compiler is correctly warning that the const is redundant as per the specification.
Note that 7.1.6.1p1 [dcl.type.cv] says that redunant cv-qualifiers are ignored, but this provision is for types created by typedef and simmilar.
Some searching revealed that GCC might have some sort of feature which allows you to have non-const elements in a const array (which seems like a terrible idea as an array in that form is really just the memory taken by its elements).
The true problem is including -Werror by default in your code release. Warnings change not only between compilers but also between compiler versions. This means that such a release is only guaranteed to build with the exact compiler and version it was developed with even though there are no real issues with the code.
I got a little carried away there since this project isn't actually written in C++, but the part about array declaration did not change from the C standard.
If you don't like -Werror then I would suggest studying the output of
./configure --help:I for one like
-Werror-- because it helps identify the bugs like this one. The bugs need fixing upon being identified, however...I got a hold of the C11 standard and in 6.7.3p9 states: "If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array type." So the second const is redundant. 6.7.3p5 says redundant qualifiers are ignored.
-Werror is known to break things with clang. The effort to build all debian packages with clang ( http://clang.debian.net/ ) lists packages that break just because they enable -Werror by default. I imagine that this would be true for any compiler that isn't compatible with the compiler a project is developed with.
If you'd like to see all the warnings clang can give you, try building with -Weverything ( http://clang.llvm.org/docs/UsersManual.html#diagnostics-enable-everything ).
Why are you wasting time on this useless discussion?
-Werror will never be removed, because it was added for a reason. If clang can't handle this, then use
--disable-quality-check.Furthermore: I'll pretend that clang does not exist until such a time that a platform that uses it goes online on OBS. So if you want to spend time on something useful work toward adding your favorite *BSD platform on OBS.
Now I remember why I love open source.
Looks like GCC no longer generates different code with or without const, i.e. both arrays are in ROM and not copied to RAM. Tested with
Fixed by git commit e7a448f9
But my statement for clang still holds true: as long as no platform on OBS uses it, SIPE compilation errors from clang will be considered as zero priority.
Thank you for taking your time fixing this bug and for your patience.