Questions tagged [compiler-warnings]

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

Compiler warnings typically flag patterns in code that could potentially cause problems, but for lack of context the compiler cannot declare absolutely that the code is flawed.

2652 questions
1
vote
0 answers

Enbale/disable c compiler warnings for specific aprt of code

I'd like to enable/disable some c compiler warnings for some specific portions of code. For example for the code printf("code: %i", code, subcode); i (obviously) get a warnings like "warning: too many arguments for format [-Wformat-extra-args]" I…
gtosto
  • 1,381
  • 1
  • 14
  • 18
1
vote
0 answers

Why usage of generic varargs gives warning but de-sugared version does not?

Consider these two methods: // All good... static T extractFirst(T[] arr) { if (arr.length > 0) return arr[0]; return null; } // Warning: "possible heap pollution from parameterized vararg type" static T extractFirstVarargs(T...…
domin
  • 1,192
  • 1
  • 7
  • 28
1
vote
0 answers

C# Use an undefined number of generic types in the signature of the generic class definition

I was checking in the c# 5,6 specs and is not clear if it is possible use a undefined number of types, such as an array, in the signature of a Generic class definition. As it is very know yu can use out paramts [] inputArrays for the…
1
vote
0 answers

How to create custom warnings for Xaml in Visual Studio 2022

As with the Roslyn CodeAnalyzers I want to be able to analyze Xaml and generate warnings with possible fixes. I came across RapidXaml which supports VS19, but not VS22. My goal is the following: Inspect Xaml Generate warning in VS22 based on…
Yakup Ipek
  • 13
  • 3
1
vote
1 answer

C Array check row and column. Issue with pointer(dereferencing NULL-Pointer warning)

I am still new to programming and this site please be nice to me an unknowing fool. I am currently working on an assignment. We need to make a Binoxxo puzzle in C and when entering a value check if it's correct according to the rules. The rules…
1
vote
2 answers

What exactly happens when a MonoBehaviour is created with new?

I'm aware that it's "not allowed"; I did this by accident and it will thoroughly be removed from my final build. Obviously there's a good reason for that rule. The weird thing is, it's in a unit testing component, and it still works perfectly in…
Michael Macha
  • 1,729
  • 1
  • 16
  • 25
1
vote
1 answer

C# IList Equals: Why is there a nullable compiler warning if the nullable typ could not be null?

I want to write my own Equals-method for two ILists. I've started with null checks and list entry counts. I thought I checked all possibilities,nevertheless after the null-checks I got the compiler-warning "Dereference of a possibly null reference."…
Spoomer
  • 38
  • 5
1
vote
1 answer

shift count >= width of type warning for 64 bit but not 32 bit

I get a "shift count >= width of type" warning for test1 but I do not get this same warning for test3. All tests appear to work and casting gets rid of the warning. However, I don't understand why I don't get a similar warning for test3. test1 and…
user17812953
1
vote
2 answers

VS2019 | C++ | Shared Pointers | Compiler Warning: The pointer points to memory allocated on the stack

I have inherited a pile of C++ code, saturated with std::shared_ptrs, most [all?] of which are unnecessary and are, I suspect, degrading performance. It is not feasible to change everything in one go, so I'm changing the code in tranches and doing…
1
vote
2 answers

Compiling New C# Versions (C# 7.0 Higher) From The Command Line

When I try to compile source code from command line with Microsoft's Visual C# Compiler (v4.8.4084.0), I get the following error and/or warning: PS C:\> csc Program.cs This compiler is provided as part of the Microsoft (R) .NET Framework, but only…
Sercan
  • 4,739
  • 3
  • 17
  • 36
1
vote
3 answers

Restructure code block so that Unused warning is eliminated

Having inherited a project from an Outsourced development company, I've been asked to modify the application and add some features. Being a bit of a perfectionist (but still relatively new) I'm trying to eliminate Warnings from the Project when I…
Paul Farry
  • 4,730
  • 2
  • 35
  • 61
1
vote
1 answer

What is the reason behind the warnings (Xst:3015) and how to rectify the same?

This is my warning message WARNING:Xst:3015 - Contents of array may be accessed with an index that does not cover the full array size or with a negative index. The RAM size is reduced to the index upper access or for only positive index…
vishnu lal
  • 23
  • 4
1
vote
0 answers

C++ macros - define " character

I know that this is absolutely not important, BUT I would like to know how to macro the start/end of a string. For a joke of course :) If I try to define " as e.g. STRING, #define STRING ", I get the following warning: warning: missing terminating…
1
vote
2 answers

warning C5246: the initialization of a subobject should be wrapped in braces

The latest Visual Studio 2019 compiling the following code with /Wall command-line switch (which enables all warnings): struct A{}; void f( const std::array & ) {} int main() { A x, y; f( { x, y } ); } prints the warning: warning…
Fedor
  • 17,146
  • 13
  • 40
  • 131
1
vote
1 answer

Problem with autoconf not making gcc with -Wall warnings

I have a simple project with a simple configure.ac script: AC_INIT(...) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES(...) AC_OUTPUT using GNU Autoconf version 2.69 (OpenSUSE Linux with gcc…
Arc
  • 412
  • 2
  • 16