Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
82 views

How to enable code analysis IDE0058 as a build error?

I want to enable IDE0058 as an error during build. Here's how I attempted to do that. Start Visual Studio 2022 (Version 17.11.2) Create new project. Project type: C#, Windows, Console -> Console ...
Thomas Weller's user avatar
5 votes
1 answer
104 views

Why -Wunused-value does not catch a statement `true;`?

Given following C code: #include <stdbool.h> int main (void) { true; return 0; } I expect that -Wunused-value would cause a warning at line 5: true; because this statement does ...
sleeptightAnsiC's user avatar
-3 votes
2 answers
140 views

Different notes for uninitialized member inside a generic lambda in GCC 9 and GCC 10

I have noticed an inconsistent behavior in my production C++17 code regarding generic lambdas and notes. I was finally able to break it down to the following minimal example. Gives a note with x86_64 ...
SoulfreezerXP's user avatar
0 votes
1 answer
42 views

How to silence warnings from 3rd party includefiles with Meson and GCC

It looks like meson is picking compiler flags from pkg-config and consequently setting include paths to dependencies using the -I flag. This leads to annoying warnings if you start turning on enough ...
skyking's user avatar
  • 14.2k
-2 votes
1 answer
97 views

Warning to discover unnamed variable

Recently I've met a bug in C++ project related to an unnamed scope guard, like in this question: LockGuard(mutex); See simple demo. This kind of bug is really hard to find by reviwing changes, and ...
Rom098's user avatar
  • 2,523
0 votes
0 answers
13 views

Alternatives to self assignment for 'breakpoint code'

I recently tried to build a project with clang and clang++. Up to now it has only been built with GCC. One of the problems that I saw was with code that is of the following form if (expression) { ...
Paul Floyd's user avatar
  • 6,550
1 vote
1 answer
44 views

Getting Warning BL0005 when modeling data for EditForm in Blazor

I am doing something like this in the Blazor HTML section... <EditForm EditContext="editContext" OnValidSubmit="SubmitQuery"> <DataAnnotationsValidator /> <...
Jbtatro's user avatar
  • 113
2 votes
2 answers
157 views

Understanding How the Compile Function Works in SBCL Common Lisp

I was hoping someone can explain why the compile function is not working as I would expect. First question: * (compile 'square (lambda (x) (* x x))) SQUARE NIL NIL But then: * (square 3) ; in: SQUARE ...
davypough's user avatar
  • 1,909
3 votes
0 answers
64 views

signed overflow warning when extracting/inserting a timepoint from/to streams

When specifying the command line options -Wstrict-overflow=4 and -O3, extracting a timepoint (e.g. std::chrono::local_seconds) from a stream object triggers some warnings from GCC (v14.1). Inserting a ...
digito_evo's user avatar
  • 3,582
0 votes
0 answers
16 views

EventHandler NRT annotation not recognized in *.designer.cs

Since NRT annotations of System.EventHandler the sender has to be nullable. If I define an event handler without correct sender declaration it will force an CS8622 error at event handler registration. ...
Sebastian Schumann's user avatar
0 votes
1 answer
76 views

Misleading unreachable warning when a type pattern match that is the result of a inline expansion is involved?

The following method works fine when T and the types of all its components are specific types (contrary to abstract type parameters). import scala.compiletime.* private inline def loop[T <: Tuple, ...
Readren's user avatar
  • 1,226
0 votes
1 answer
84 views

Cannot assemble my code: waring: warning: relocation in read-only section `.text', warning: creating DT_TEXTREL in a PIE

I tried to replicate the assembly workspace that i have to study on my windows pc (where i have instruction to how installe and use wsl) on my linux pc but when i try to assemble by using ./assemble....
Francesco Bonistalli's user avatar
0 votes
0 answers
75 views

Can I ask GCC to give me a warning or error on empty structs?

I just had the worst problem ever in my mixed C/C++ project. The C code is the production code, the C++ is the testing environment. We are compiling with MinGW GCC, but developing on Qt Creator which ...
Charles's user avatar
  • 1,187
1 vote
1 answer
177 views

Terraform Warning: Interpolation-only expressions are deprecated

I got this warning: Warning: Interpolation-only expressions are deprecated on best.tf line 69, in locals: 69: pools = length(var.instances) > 0 ? { "${var.name}" = var....
Positive Navid's user avatar
0 votes
0 answers
52 views

Windows CPP compiler ignore specific warnings and treat every warning as error

I am following this documentation I want to treat all warnings as error and ignore these specific warnings but I get an error: set _CL_="-WX -WD28020 -WD28112 -WD28132 -WD28159 -WD28182 -WD28195 -...
Node.JS's user avatar
  • 1,483
0 votes
0 answers
248 views

How does my system's GCC silence PSTL warnings?

When I compile even the simplest program using a C++ standard library algorithm execution policy, I get a page or two of warnings from include/c++/14.0.1/pstl/algorithm_impl.h - centred on the message ...
user2023370's user avatar
  • 10.9k
1 vote
2 answers
181 views

Being inundated with macro redefinition from ntstatus.h

Despite having added the #define, I am still receiving the same bunch of warnings, twice (as many times the below header is #included) for a total of 100+ warnings: #ifndef UMDF_USING_NTSTATUS #define ...
BusterZo's user avatar
1 vote
3 answers
97 views

GCC -Woverride-init warning with anonymous structs in a union

I need to define a type formed with 2 24-bit fields (48 bits in total). I didn't find a way to do it with bitfields in a struct. So I defined my type with a union and 2 anonymous structs : typedef ...
clem822's user avatar
  • 11
3 votes
1 answer
130 views

Missing GCC "-Wformat" warnings for "%p" with char* etc

If I compile the following code with -std=c17 -Wall -Wextra -Wpedantic with GCC 13.2.0, I get no warnings, despite not using void* in arguments corresponding to "%p" format specifiers. #...
Wolf's user avatar
  • 10k
1 vote
2 answers
108 views

Can I suppress rule CS9035 once?

I have an Options class like this (note the required keyword): public class Options { [Required] public required string Endpoint { get; set; } } It is loaded from the configuration like this: ...
Jack Miller's user avatar
  • 7,508
0 votes
0 answers
59 views

Execution failed for task ':app:compileDebugKotlin'. Could not resolve all files for configuration ':app:kotlin-extension'

I tried changing the Kotlin version since mine wasn't compatible with the compiler, as suggested in the error, i changed the version from 1.9.0 to 1.8.10, but then i received an error which stated ...
Shahdiya_S's user avatar
0 votes
1 answer
84 views

Cast function pointer to void* in function invocation then recast them to original type

I have a struct that contains a function callback that's being defined differently depending on the compiler typedef struct structA { #ifdef _compilerA_ void (*func) (int); int param; #else void ...
shjnlee's user avatar
  • 243
4 votes
2 answers
150 views

Integer overflow warning only when using const keyword

I'm encountering a warning with the const keyword in C++ when using clang++ v. 17.0.1 or newer, with the flag -Winteger-overflow. Here's the code snippet: int foo_const() { const auto min = std::...
Daniele Pallastrelli's user avatar
0 votes
0 answers
174 views

Angular 17.1.0 "ng serve" command sometimes doesn't work

When I serve my angular 17 project it takes a lot of time to run and sometimes it serve but sometimes it doesn't. When it doesn't serve it gives me this error: Angular build : An unhandled exception ...
Q U R A N A L K A R E M's user avatar
0 votes
0 answers
33 views

warning: implicit declaration of function ‘yyerror’; did you mean ‘yyerrok’

warning: implicit declaration of function ‘yyerror’; did you mean ‘yyerrok’? [-Wimplicit-function-declaration] 1149 | yyerror (YY_("syntax error")); enter image description here any ...
Shoaib Shoobi's user avatar
1 vote
1 answer
295 views

Can't get IDE0130 to show up in VS2022 error list

I'm using Visual Studio 2022 Community, and C# projects. I like my namespaces to match my folder structures, so when I move a file from one folder to another within VS, I always accept the popup ...
Bob Vesterman's user avatar
0 votes
0 answers
58 views

PKG not resolving any path directory methodsduring compilation (path join __dirname process.cwd())

According to various statements in the PKG docs and support forums, the compilation is supposed to work without PKG config in package.json I am getting the following warnings - resulting in a failure. ...
IoT-Practitioner's user avatar
1 vote
0 answers
71 views

Neither -Wunused-result, nor --warn-unused-result generates warnings about unused results

This (simplest-example) program is set up so main() calls the makeKey() function and fails to check the return value ...Which demonstrates why, when programming, especially security critical code [I'm ...
BlueChip's user avatar
  • 160
0 votes
0 answers
15 views

Why do I not get a warning when I print a variable without initialising a value? (CodeBlocks 20.03)

enter image description herewhen I compile and run the code I see 4200987 being printed. enter image description hereThis is what I get when instead I should be getting a warning. What do I change and ...
shreyash1611peep's user avatar
3 votes
1 answer
114 views

GCC/Clang vs. MSVC: Missing Wconversion warning in template function with std::invoke

I'm encountering an issue where a template function uses std::invoke to call another function, passing a size_t argument to a parameter expecting an int32_t. This should, theoretically, trigger a ...
Patryk Kowalski's user avatar
2 votes
2 answers
156 views

Can I get MSVC to be less strict about "C4127: conditional expression is constant"

I'm using MSVC 16 2019 with many warnings turned on, including C4127: conditional expression is constant. However, I have code which looks like: template <bool B> void foo(int x) { if (B &...
einpoklum's user avatar
  • 128k
3 votes
1 answer
227 views

Is g++ -Wdangling-reference warning justified in this case?

Compiling my code with gcc 13.2 and -Wdangling-reference I was surprised that in this simple scenario (godbolt): #include <vector> #include <string> std::string& add_variable(std::...
MatG's user avatar
  • 736
1 vote
0 answers
592 views

How to tell clang-tidy to ignore some headers?

I have some C++ header files in a project that trigger clang-tidy warnings. For various reasons I cannot edit those files (to fix the warnings or to //NOLINT them) at this time, but I would still like ...
Alex O's user avatar
  • 1,639
0 votes
1 answer
114 views

GCC warning for uninitialized data seems opposite of what the standard says

Detailed code is given below, but basically: I have a class with some uninitialized data (not set in the ctor). When copying an instance of this class under certain circumstances, GCC gives no warning,...
jwd's user avatar
  • 11k
1 vote
1 answer
198 views

How to suppress SYSLIB0051 in a globl suppressions file

In some generated code, which I cannot change and for which I cannot modify the generator, after updating to .NET 8, I get a number of SYSLIB0051 warnings. I thought it should be straightforward to ...
Martin's user avatar
  • 2,066
2 votes
0 answers
140 views

GCC warning: how to ignore -Wswitch-default on enum

The following code presents 3 cases where I want or don't want GCC warnings: # include <iostream> enum class MyEnum { FOO, BAR, BAZ }; int main() { // Case 1 int const a = 3; ...
Caduchon's user avatar
  • 5,142
-1 votes
2 answers
102 views

Why Does Visual Studio Give the Warning "Relational Expression As Switch Expression"?

I have the following code: float x = 0.43; float y = 1.56; size_t largerValueIndex = 1; size_t smallerValueIndex = 0; switch (x > y) { case 1: largerValueIndex = 0; smallerValueIndex = 1; ...
golightlydev's user avatar
1 vote
0 answers
89 views

Is there a GCC/Clang attribute to mark which fields in a struct that a given mutex covers?

I'm thinking about how I would theoretically implement a multi threaded queue from first principles, using only glibc on POSIX. Obviously, this is going to require a mutex (or some other locking/...
ijustlovemath's user avatar
0 votes
2 answers
160 views

why does gcc have to recognize int64 as long int?

This is how LWT_ELEMID defined in liblwgeom_topo.h: typedef int64_t LWT_INT64; typedef LWT_INT64 LWT_ELEMID; I include this .h file and define some argument in LWT_ELEMID type. But it always warns me ...
HelpMePlease's user avatar
1 vote
1 answer
60 views

No CS0184 warning for impossible check

Why does testB in this example not give a "warning CS0184: The given expression is never of the provided ('MyClass2') type" the same way that testA does? class Program { void Main() {...
innominate227's user avatar
0 votes
1 answer
133 views

Visual Studio : warnings show in the filter but not in the list

I work on a legacy solution that has hundreds of warnings that I don't want to address now. So I filter them out. The filter still has numerous files, for example this file whose name starts with an L ...
Jean-David Lanz's user avatar
2 votes
1 answer
207 views

CA1508: 'null => true' is always 'true'. Remove or refactor the condition(s) to avoid dead code

I'm encountering an interesting scenario with the CA1508 warning in C# when using a switch expression with a nullable DateTime property. Specifically, I have a property that determines if there are ...
Imperiestro Mongo's user avatar
0 votes
2 answers
127 views

-Wstringop-overflow warning when length allocated to destination string is equal to source

I am using GCC 10.2.0 with C++17, and I get the following error: ioapi.c: In function ‘file_build_ioposix’: ioapi.c:125:5: warning: ‘strncpy’ specified bound depends on the length of the source ...
ChrisAB's user avatar
  • 11
1 vote
2 answers
287 views

Is it false positive here: warning C4172: returning address of local variable or temporary?

In the following code: #include <execution> #include <vector> template<typename T> class Index { public: const std::string& text; const std::vector<T>& ...
Damir Tenishev's user avatar
0 votes
0 answers
26 views

possible lossy conversion from int to short but I have no int variable

I was writing a code to print out the reverse of the 4-digit numbers, so my maximum number is 9999 and below 32767(maximum value of short) . The code is : public class Project2{ public static void ...
mohamad hashemi's user avatar
2 votes
1 answer
85 views

Count in substring - fix compiler warnings

The count_occurences code finds the number of occurrences of character c in the string between positions start (included) and end (excluded). E.g. the following code counts , in ,b, (substring of a,b,...
Dmitry's user avatar
  • 362
0 votes
0 answers
234 views

Using pragma in .c and .h file

I am using pragma like this in .c file: #pragma ghs startdata #pragma ghs section bss=".BSS" static int A; #pragma ghs section bss=default #pragma ghs enddata in .h file: extern int A; ...
Bui Ngoc Minh's user avatar
0 votes
0 answers
171 views

Unresolved attribute reference 'astype' for class 'bool'

I moved from Jupyter lab to Spyder and have a program that seems to work fine. Problem is its taking ages to write and Im getting lost in all the modifications, so I moved to GitHub, which obliges me ...
AndysPythonStuff's user avatar
1 vote
2 answers
274 views

GCC warns of out-of-bounds access only in a static_cast

GCC warns of out-of-bounds array access only when used in a static_cast even with most of the warning options enabled. The sample code (live): #include <iterator> #include <numeric> #...
digito_evo's user avatar
  • 3,582
1 vote
0 answers
68 views

cannot open source file "stdio.h" in one file in a directory

I am running wsl on vscode. I have a directory consisting of two c files with similar content. Both are using the stdio. But only one of them is showing error squiggles. If I am creating a new file ...
Bolt's user avatar
  • 11

1
2 3 4 5
55