compiler-warnings

Why do I get warning CS0108 about a property hiding a method from a base class [duplicate]

空扰寡人 提交于 2021-01-28 02:00:14
问题 This question already has answers here : Why is a property hiding Inherited function with same name? (2 answers) Closed 3 years ago . Given the following classes the C# compiler gives me this warning:- CS0108 "'B.Example' hides inherited member 'A.Example(string)'. Use the new keyword if hiding was intended". class A { public string Example(string something) { return something; } } class B : A { public string Example => "B"; } If use the classes running this code class Program { static void

How do I access global variables in local scope without “possibly used before declaration” -errors?

青春壹個敷衍的年華 提交于 2021-01-28 01:42:45
问题 I'm getting this warning: WARNING: $a possibly used before declaration. for my function: Func test() If (IsDeclared("a")) Then ConsoleWrite($a) Else ConsoleWrite("Not declared") EndIf EndFunc Global $a = "test" test() Can be avoided by using the global variable as a parameter to the function. But I need this construct because it's tied to a file-operation which I don't want to execute every time I need the variable. How can I do this without generating a "possibly used before declaration"

How to detect compiler warnings in gitlab CI

旧城冷巷雨未停 提交于 2021-01-27 20:06:23
问题 In the steps of setting up CI builds on our gitlab server, I can't seem to find information on how to set up the detection of compiler warnings. Example build output: [100%] Building CXX object somefile.cpp.o /home/gitlab-runner/builds/XXXXXXX/0/group/project/src/somefile.cpp:14:2: warning: #warning ("This is a warning to test gitlab") [-Wcpp] #warning("This is a warning to test gitlab") ^ However the build result is success instead of warning or something similar. Ideally the results wuold

[[maybe_unused]] on member variable, GCC warns (incorrectly?) that attribute is ignored

落爺英雄遲暮 提交于 2021-01-26 22:51:20
问题 In the following example: struct Foo { [[maybe_unused]] int member = 1; void bar() { [[maybe_unused]] int local = 0; } }; int main(int argc, char* argv[]) { Foo f{}; f.bar(); return 0; } GCC emits a warning where Clang and MSVC do not: warning: 'maybe_unused' attribute ignored [-Wattributes] [[maybe_unused]] int member = 1; As far as I can tell, this should be legal (and not ignored by the compiler). According to the standard: 10.6.7 Maybe unused attribute [dcl.attr.unused] ... 2. The

[[maybe_unused]] on member variable, GCC warns (incorrectly?) that attribute is ignored

自闭症网瘾萝莉.ら 提交于 2021-01-26 22:50:10
问题 In the following example: struct Foo { [[maybe_unused]] int member = 1; void bar() { [[maybe_unused]] int local = 0; } }; int main(int argc, char* argv[]) { Foo f{}; f.bar(); return 0; } GCC emits a warning where Clang and MSVC do not: warning: 'maybe_unused' attribute ignored [-Wattributes] [[maybe_unused]] int member = 1; As far as I can tell, this should be legal (and not ignored by the compiler). According to the standard: 10.6.7 Maybe unused attribute [dcl.attr.unused] ... 2. The

[[maybe_unused]] on member variable, GCC warns (incorrectly?) that attribute is ignored

不打扰是莪最后的温柔 提交于 2021-01-26 22:49:29
问题 In the following example: struct Foo { [[maybe_unused]] int member = 1; void bar() { [[maybe_unused]] int local = 0; } }; int main(int argc, char* argv[]) { Foo f{}; f.bar(); return 0; } GCC emits a warning where Clang and MSVC do not: warning: 'maybe_unused' attribute ignored [-Wattributes] [[maybe_unused]] int member = 1; As far as I can tell, this should be legal (and not ignored by the compiler). According to the standard: 10.6.7 Maybe unused attribute [dcl.attr.unused] ... 2. The

Is there a `clang++:-Wunused-lambda-capture` equivalent warning in/being developed for GCC?

旧城冷巷雨未停 提交于 2021-01-05 07:58:46
问题 Background I sometimes run into code that use the following dummy lambda-capture (instead of e.g. (void)x; , ... foo(int /* x */) or ... foo([[maybe_unused]] int x) in C++17) in order to remedy an unused variable warning: void foo(int x) { [&x]{}(); } Now, this is not really a remedy, as it passes the warning over from the current scope to the lambda capture instead, but afaik, GCC has no diagnostic to flag this, whereas e.g. Clang (as of 5.0) emits the unused-lambda-capture warning, if

“redundant cast to java.lang.Object” warning for necessary cast

一笑奈何 提交于 2020-12-28 06:51:45
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

“redundant cast to java.lang.Object” warning for necessary cast

爱⌒轻易说出口 提交于 2020-12-28 06:49:10
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

“redundant cast to java.lang.Object” warning for necessary cast

雨燕双飞 提交于 2020-12-28 06:47:48
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf