3

In the following code:

    Public Structure MyDate
    Public year As Integer
    Public month As Integer
End Structure

Public Function GetMyDate() As MyDate

End Function

Public Function GetSystemDate() As Date

End Function

Public Function GetListview() As ListView

End Function

Public Function GetInteger() As Integer

End Function

Visual Studio 2015 issues warnings that GetSystemDate, GetListview and GetInteger "doesn't return a value on all code paths" but it is silent on GetMyDate.

Is there a sensible reason for this or perhaps it's a bug?

Gwynge
  • 125
  • 7
  • 2
    A similar bug (for all structures) was reported several years ago(see:[BC42105 does not fire for structures](https://connect.microsoft.com/VisualStudio/feedback/details/488430/bc42105-does-not-fire-for-structures)) and supposedly fixed for VS2010. However, it appears that a User defined structure still causes the issue in VS2010 and above. You could try reporting it. – TnTinMn Mar 09 '17 at 15:55
  • @TnTinMn : You should post that as the answer. That's the most correct one so far. – Visual Vincent Mar 09 '17 at 16:02
  • 1
    This is by design. Pretty visible from Project > Properties > Compile tab. The warning settings are named well "Function returning reference type" and "Function returning intrinsic value type". So not a structure. Having to stay compatible with previous VB versions is not much joy. This settings page is badly broken in VS2017 btw, that is no joy either. Who tests this stuff, looks like nobody. – Hans Passant Mar 09 '17 at 16:39

1 Answers1

3

A similar bug (for all structures) was reported several years ago (see:BC42105 does not fire for structures) and supposedly fixed for VS2010.

Contrary to what I posted in the comments section, this bug is not limited to user defined types. It appears that any structure that is not a numeric type will suffer this from this bug. For instance, this will also not yield a warning.

Function colr() As System.Drawing.Color
End Function
TnTinMn
  • 10,805
  • 3
  • 13
  • 37
  • I have now registered a new issue https://connect.microsoft.com/VisualStudio/feedback/details/3128109 – Gwynge Mar 10 '17 at 12:40