Questions tagged [unchecked-conversion]

The `unchecked` keyword is in .NET used to suppress overflow-checking for integral-type arithmetic operations and conversions.

In an unchecked context, if an expression produces a value that is outside the range of the destination type, the overflow is not flagged.

More info with examples on MSDN.

31 questions
1
vote
2 answers

Regarding Unchecked_Conversion in ada

Could anyone please explain me the operation of ada.unchecked_coversion(float, UnsignedInteger). What this operation will be performed ? Could anyone please clarify this with example. Thanks a lot in advance.
1
vote
0 answers

Lists and unchecked conversions

In trying to fix a warning about "Type safety: The expression of type List needs unchecked conversion to conform to List". Basically taking a List of Objects and casting it to a List of InventoryPDFAdapter. This was the code which was throwing the…
1
vote
3 answers

What is the consequence of ignoring the warning:unchecked conversion in java

I know why I am getting the warning(i.e assigning raw type to parameterized type), but I don't exactly get what will be possible sequences if I ignore the warning. List list = new ArrayList(); List iList = list; // warning:…
The Scientific Method
  • 2,374
  • 2
  • 14
  • 25
1
vote
1 answer

Unchecked generics warning in Scala?

I've written a NaturalComparator class/object in Java and rewritten it into Scala: https://gist.github.com/319827#file_natural_comparator.scala However, I wonder why I don't need to @SuppressWarnings("unchecked") in the Scala version. (I compile it…
v6ak
  • 1,636
  • 2
  • 12
  • 27
1
vote
3 answers

why am i getting the warning [unchecked] unchecked conversion?

Can anyone please point me what I am missing over in the below statements? Warning 1 prog.java:16: warning: [unchecked] unchecked conversion adj = new LinkedList[v]; ^ required: LinkedList[] found: …
1
vote
3 answers

Is it guaranteed that outer checked/unchecked context influences the behavior of lambdas created inside it?

Assuming default arithmetic overflow (not)checking, the following code Action action; checked { action = array => Console.WriteLine(array[0] + array[1]); } var items = new[] { Int32.MaxValue, …
Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53
1
vote
2 answers

Unchecked conversion when popping stack Java

I'm new to Java and have a question about a warning: My general code: private Stack stackFrame = new Stack(); private ArrayList curBlocKList = new ArrayList(); ... curBlockList = stackFrame.pop(); I'm…
David
  • 216
  • 2
  • 10
1
vote
2 answers

Java generic list gives me warning

I don't understand why Java compiler gives me 'unchecked conversion' warning in the following situation: I have this class: public class NodeTree { T value; NodeTree parent; List> childs; NodeTree(T value, NodeTree…
MarcoSuma
  • 59
  • 10
1
vote
3 answers

Why does this throw an OverflowException?

I have the following code in a method to convert any number in to a byte: try { return (byte) Convert.ChangeType(operand.RealValue, TypeCode.Byte); } catch (OverflowException) { if (AllowArithmeticOverflow) { unchecked { …
Xenoprimate
  • 7,691
  • 15
  • 58
  • 95
1
vote
2 answers

ada: unchecked Conversions and multi-level arrays

I am working on a program that needs to write a gigantic, multilayer array to several smaller buffers. I am looking to do this by using unchecked_conversion to flatten the multilayer array into a single layer array, then slice up the array. To…
SquidsEnMasse
  • 716
  • 2
  • 7
  • 17
0
votes
1 answer

Get rid of Unchecked overriding: return type requires unchecked conversion

Example code similar to my code. public interface Builder { B build(A a); } public class ClientBuilder implements Builder { @Override public String build(Integer i) { return i.toString(); } } public abstract…
idkwat2do
  • 449
  • 1
  • 4
  • 13
0
votes
1 answer

Unchecked conversion warning of List

When I compile my java code with -Xlint:unchecked, in this line: List list = hier.getHierarchyNodesParentFirst(0); I receive this: ... unchecked conversion required:…
Shayan
  • 2,758
  • 7
  • 36
  • 55
0
votes
1 answer

Mapping chunk of shared memory for reading/writing in Ada

I have a chunk (1024 bytes) of shared memory between two processes for which I have an address pointing to. I want to copy some data to this shared memory, and read it on the other process. Coming from a C background, it seems easiest to map a…
Casey Kuball
  • 7,717
  • 5
  • 38
  • 70
0
votes
1 answer

Unchecked Warning for ChangeListener-Parameter

In a JavaFX application I attached a ChangeListener to a TableCell's tableRowProperty, which is of type ChangeListener (and TableRow is generic too). What I did was the following: public final class PairingResultEditingCell…
Matthias Meid
  • 12,455
  • 7
  • 45
  • 79
-1
votes
1 answer

Java ArrayList type error/warning

While attempting to implement a custom data class I have run into the following problem. I'm simply trying to add items to an ArrayList but Java seems to have an issue with the types I'm using. I have tried multiple solutions to no avail. Below I…