Questions tagged [compiler-warnings]

Messages emitted by a compiler which indicate potential problems in code or configuration.

Filter by
Sorted by
Tagged with
-2 votes
0 answers
57 views

Warning in printf() about different types cannot be silenced, even after using -Wno-format-signedness

Im trying to silence the warning about a printf that has different signed/unsigned types. The code is quite easy: int value = 10; printf("here a test %ld \n", value); https://...
Aitorhub's user avatar
0 votes
0 answers
25 views

whenever I run ng serve I encounter problem

This issue is persisting X [ERROR] NG8001: 'app-header' is not a known element: 1. If 'app-header' is an Angular component, then verify that it is part of this module. 2. If 'app-header' is a Web ...
Behroze f2f Khalid's user avatar
1 vote
2 answers
210 views

Conditional compile-time warning in C++

I am implementing my own analogue of std::expected for C++17, and I am writing a method that takes a function and invokes it on the successful value of the expected. If the expected contains error, ...
Mikhail Tsaritsyn's user avatar
1 vote
1 answer
41 views

assembly:SuppressMessage for CS8981

I'm trying to suppress warning CS8981 for migrations. I tried like this, but it doesn't work: [assembly:SuppressMessage( "Microsoft.Naming", "CS8981:The type name only contains ...
Anna Melashkina's user avatar
-1 votes
2 answers
114 views

C# What is the best way to RESOLVE the warning compilation "CS8618"

If we declare property like this: public class Cat { public string Name { get; set; } } we get a warning compilation: CS8618 - Non-nullable variable must contain a non-null value when exiting ...
Oleg Sh's user avatar
  • 8,608
-4 votes
0 answers
118 views

Delphi XE7 - hints and warnings that do not exist in the code [closed]

We have Delphi XE7, and when we compile our code, we are getting hints and warnings that do not exist in the code. See some of the examples we are getting below. Has anyone see anything similar to ...
MRoth's user avatar
  • 55
0 votes
0 answers
24 views

Attribute to declare that a method always throws an exception, to satisfy BC42105

Compiler Warning BC42105 occurs when there are branches in a function that will not return a value or throw an exception. However, I have a situation where I throw the exception in a called method and ...
Perringaiden's user avatar
0 votes
0 answers
30 views

Overly strict [-Wrange-loop-construct] in gcc-12?

I have just upgraded to GCC/G++-12.2(with the Debian12 official apt repo) from gcc-10.5.0, and recompiled my old codes. g++-12 gave me a lot of warnings like this: my_source.cpp:60:25: warning: loop ...
Leon's user avatar
  • 1,651
0 votes
1 answer
49 views

"warning: field `somebool` is never read" for struct field only referenced in second, non-trait impl

This may be a feature I don't know yet. I have this compiler message: $ cargo build --lib Compiling secondimpl v0.1.0 (/home/nsdd/garage/sames/rustex/secondimpl) warning: field `somebool` is never ...
user3713271's user avatar
0 votes
0 answers
46 views

Why aren't the bindingRedirects in web.config working in my Web Project?

(IDE is Jetbrains Rider, in case relevant) Setup: Create a blank "ASP.NET Web Application" project Add dependencies in Nuget: System.IdentityModel.Tokens.Jwt, version="4.0.4.403061554&...
Brondahl's user avatar
  • 7,632
0 votes
0 answers
39 views

Will #pragma GCC diagnostic ignored be applied only per compilation unit?

Can't find any concrete documentation about GCC. Question is: if I set (for example) a #pragma GCC diagnostic ignored "{some-diag}" on a .cpp file, will this be applied only after this ...
markzzz's user avatar
  • 47.6k
0 votes
1 answer
28 views

Kotlin: Ensure method is called for type during compile time

We have a logic implemented in our app that allows for other objects to be referenced in the DB models by their IDs. If the object of that type, with that ID is not on the DB, then we fetch it and ...
Felipe Ribeiro R. Magalhaes's user avatar
1 vote
0 answers
32 views

Clang erroneous unneeded-internal-declaration warning?

clang++ (17.0.1) gives a warning for this code: #include <iostream> namespace { void fun () { std::cout << "fun\n"; } } // namespace template<class T> ...
user2052436's user avatar
  • 4,441
3 votes
1 answer
85 views

PL/SQL - Avoid Compiler warning: "value assigned, never used"

As you've probably gathered, the code below isn't real - but it highlights my point. PROCEDURE Do_Some_Dynamic_Stuff ( sql_ IN VARCHAR2 ) IS cur_ INTEGER := Dbms_Sql.Open_Cursor; res_ ...
cartbeforehorse's user avatar
0 votes
1 answer
47 views

Warning with 'init(validatingUTF8:)' in Swift

I'm working with a piece of Swift code (from here) that takes a modelCode and checks against a modelMap dictionary to get a model. When the model is a simulator, it checks the simulator's model ...
FrugalResolution's user avatar
0 votes
1 answer
30 views

if targetEnvironment(simulator) Code after 'return' will never be executed

I get the Xcode warning: "Code after 'return' will never be executed", when I use this: #if targetEnvironment(simulator) return #endif //Stuff that a simulator is unable to do I use ...
Bob de Graaf's user avatar
  • 2,652
5 votes
1 answer
118 views

Why does using conditional operator ? : causes returning local temporary object?

I run into a problem where using the conditional operator returns garbage string_view in MSVC, because the string_view was backed by a temp object?. #include <string> #include <iostream> ...
Tony J's user avatar
  • 651
-1 votes
1 answer
69 views

After deleting the wrong content, it will still be marked in red until compiled again

There is something wrong with my vscode. When a compilation error occurred, I corrected the error, but the correction will not be reflected in the red mark untill compiled again. g++ version 13.1.0 ...
mais ado's user avatar
1 vote
2 answers
102 views

Can't get rid of the C++ warning

I am new to C++ and this warning has been driving me crazy. Warning C4244 'argument': conversion from 'double' to 'int', possible loss of data at line 41 The line is: ((x == 1) || (x == -1)) ? (...
Nadia's user avatar
  • 15
0 votes
0 answers
26 views

How to handle deprecated warning for CLOB_DURATION_SESSION

In my java code we have upgraded to latest ojdbc version in order to support JDK17, but started getting below warnings: The field CLOB.DURATION_SESSION is deprecated. The type CLOB is deprecated. Don'...
Bharat Pati's user avatar
2 votes
1 answer
43 views

Wrong results defining a function inside a if-statement in a function scope in Julia

I find it somewhat strange that it works fine globally, but within a function scope, the compiler resorts to defining a function inside the ifelse statement, which I explicitly set to false. ...
Isak Hammer's user avatar
1 vote
2 answers
99 views

How to tell the compiler to throw errors for the variables that are not declared as "volatile" but used within an interrupt handler?

We need to declare the variables that are not meant to be enregistered or optimized as volatile if they are only modified within an external event (within an interrupt in embedded domain). uint8_t ...
ceremcem's user avatar
  • 3,970
0 votes
0 answers
60 views

static OnceLock gets seemingly erroneous "is never used" warning

I have this in lib.rs: static REQWEST_CLIENT: OnceLock<Client> = OnceLock::new(); pub fn get_reqwest_client() -> &'static Client { REQWEST_CLIENT.get_or_init(|| { let es_path ...
mike rodent's user avatar
  • 14.4k
2 votes
1 answer
38 views

Is there a way to ignore warnings in dependent packages? Is there a way to #if an os that the compiler doesn't know about?

I am using Swift Playgrounds to do App Development. One of my dependencies has some code like this: #if os(visionOS) That causes my app to have a warning due to Swift Playgrounds not being updated ...
Kudit's user avatar
  • 4,264
1 vote
0 answers
22 views

Indexing Properties with accurate keyof typeof type [duplicate]

Why can I not index variable y with the keys from x? interface A { a: string; b: number; e: boolean; }; declare let x: A; declare let y: A; let t: keyof typeof x; for (t in x) { y[t] = ...
dlynch's user avatar
  • 35
0 votes
3 answers
123 views

How to suppress a specific unused-but-set-variable warning?

I've got some old code I'm trying to compile on a new(er) compiler (armclang 6.18), and I'm currently working through resolving a lot of new warnings. One I can't seem to get past is a variable that's ...
Chris Robison's user avatar
0 votes
1 answer
404 views

What is a "this-escape" warning, and how do I deal with it?

I struggle to find resources on this, and yet, so many of my classes are running into this error when I compile my code on the latest Java (21). Here is a code example. public class ThisEscapeExample {...
davidalayachew's user avatar
0 votes
1 answer
18 views

How to ignore compiler warnings in Eclipse for generated code when using Gradle's Eclipse plugin?

I have a Java library that includes a large amount of generated code in the src/gen/java directory. The code generator isn't very mature, so the generated code triggers tons of Eclipse warnings. ...
jstricker's user avatar
  • 2,132
1 vote
0 answers
70 views

Why does the xlc switch -qhaltonmsg not work?

I am usng AIX xlc and attempting to use the -qhaltonmsg=... switch to make certain detected messages fatal. It's not working and I can't figure out why. Here is a sample program: int main() { foo()...
Greg Hewgill's user avatar
1 vote
0 answers
95 views

Why is compiler mis-stating namespace?

Doing some C++ development after a good four years in Python, it appears I'm a little rusty. I have three files in my very cut-down example (the actual code is much larger but this example still ...
paxdiablo's user avatar
  • 860k
0 votes
2 answers
110 views

invalid conversion from void* to struct* in C++

I have a problem related with this implementation : struct arg_struct { int low; int high; }*args; void segmentedSieve(void * arguments) { arg_struct *args = arguments; /****do ...
DeadlyKitten999's user avatar
-1 votes
1 answer
109 views

"The property ... was not found in type ...", why doesn't this appear in build results?

I'm working on a C# WPF application, using Visual Studio 2022. While running the application, I saw a checkbox, whose value did not change, although it should. This was caused by the following typo in ...
Dominique's user avatar
  • 16.3k
0 votes
0 answers
48 views

Why it is possible to use moved variable [duplicate]

Using a value after it has been moved can lead to erroneous code (MWE below). I understand that in cases where everything is copied, using the variable after a move is valid. However, it seems ...
Fanteria's user avatar
-2 votes
1 answer
76 views

Why does -Wparentheses raise a warning if unnecessary parentheses are absent around assignment used as truth value in an if statement? [duplicate]

-Wparentheses is giving me a warning on the following snippet: long n = -1; bool asking = true; do { ask_into("Enter the order of this Bezier curve (# of points):", n); if (asking = n &...
Lily-Heather Crawford's user avatar
3 votes
0 answers
116 views

MSVC 19.37 doesn't consistently warn on assignment in if statements

A colleague prefers Yoda Conditionals: if (0 == x) // as a safer alternative to (x == 0), to prevent the typo (x = 0) This is a controversial style in the team, and one argument brought up against ...
Jan Schultke's user avatar
  • 22.4k
0 votes
0 answers
16 views

XCode 12, double clicking warnings doesn't work

I'm trying to bring some really old C++ code back online, using Xcode 12. Lots of errors and warnings. And...although each shows a filename (in red) and line number, when I double-click on the ...
Joymaker's user avatar
  • 943
2 votes
0 answers
115 views

New array-bounds and stringop-overflow GCC 13 warnings in spdlog+gtest program

I updated the operating system from Fedora 37 to Fedora 38, and my program started to produce new compilation warnings: array-bounds and stringop-overflow. The program depends on the libraries from ...
Fedor's user avatar
  • 17.6k
1 vote
0 answers
53 views

How to find code (eg functions) that is not referenced by any other code?

Every time I come back to rust I am baffled by how the warnings for unused code work, they're transitive! Even if function f is called from function g, f will still be considered unused if g is unused....
withstanding_crepe's user avatar
1 vote
1 answer
107 views

How to treat C/C++ extension diagnostic warning as error?

I am using the C/C++ extension for vscode and have the diagnostics/clang-tidy enabled. However, it underlines diagnostic errors as yellow/warning even though the resulting code would not compile at ...
Raildex's user avatar
  • 3,587
11 votes
2 answers
1k views

How to fix code to avoid warning -Wunsafe-buffer-usage

Before clang 16.0 I was able to compile all my projects using -Weveything without problems, fixing my code and paying attention to the (useful) warnings that this option gave. However, it seems that ...
user avatar
1 vote
2 answers
65 views

warning for initialized enum variable : type defaults to 'int' in declaration of 'etatCourant' [-Wimplicit-int]

I'm having a warning when I tried to initialize my enum variable. Here is the code : enum etatCourant {REPOS, MARCHE_AV, MARCHE_AR, ERREUR}; etatCourant = REPOS; Here is the warning : type defaults ...
Classy Fied's user avatar
1 vote
2 answers
74 views

Is there a robust way to set a compiler flag in CMake, overriding/replacing another if it exists?

I have a global CMakeLists.txt that sets a bunch of global compile options (examples will use MSVC, but it's not exclusive to it, just that cl.exe generates warnings when it encounters flags override),...
Dan M.'s user avatar
  • 3,840
2 votes
1 answer
125 views

How to trigger an error/warning immediately upon compile/run if an item on my class-path is missing

I have a very simple source file -- HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("hello world"); } } I have the ...
davidalayachew's user avatar
37 votes
6 answers
3k views

How can I get a warning when comparing unsigned integers of different sizes in C and C++?

A common source of bugs in C or C++ is a code like this: size_t n = // ... for (unsigned int i = 0; i < n; i++) // ... which can infinite-loop when the unsigned int overflows. For example, on ...
nh2's user avatar
  • 24.7k
1 vote
3 answers
127 views

Why does "dangling-else" emit a warning?

I have a program. Somewhere in the program, I have this code: int read_n(char *cp, int n) { int nread; if ((nread = read(STDIN_FILENO, cp, n)) != n) if (nread == -1) die(DIE_ERROR_FMT, &...
user129393192's user avatar
0 votes
0 answers
22 views

Why does GCC 11.3.0 generate -Wformat warning on my x86_64 machine, but doesn't on godbolt x86_64 machine?

$ uname -m x86_64 $ cat t56.c #include <stdint.h> #include <stdio.h> int main(void) { typedef struct { uint64_t v; } float64_t; union { double tf; float64_t f; } uX = {0}; ...
pmor's user avatar
  • 5,593
-4 votes
4 answers
154 views

Why is the dereferencing operator not used with a string pointer?

Why the indirection/dereferencing operator (*) is used with a pointer of any data type except a string? 'char' In the following program the letter 'A' and the string "Computer" are stored ...
user10897549's user avatar
6 votes
1 answer
112 views

why g++ issue (and not issue) -Wreturn-type warnings

#include <array> #include <iostream> #include <string> using namespace std; template <typename T> class MyClass { public: // even not called, g() has -Wreturn-type warning ...
shan's user avatar
  • 218
2 votes
1 answer
87 views

Converting null literal or possible null value to non-nullable type DESPITE null-coalescing operator

I'm still quite new to C# (about 4months in) and I don't understand why this would be an issue. Run on DotNet Fiddle #nullable enable using System; using System.Text.Json; using System.Text.Json.Nodes;...
infinitezero's user avatar
  • 1,769
0 votes
0 answers
26 views

Typescript compiler not emitting errors in browser environment

I was making a code editor for typescript that runs within browser. For transpilation, i decided to use the typescript compiler (https://cdnjs.cloudflare.com/ajax/libs/typescript/5.1.6/typescript.min....
LegenDrags's user avatar

1
2 3 4 5
54