472,355 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,355 software developers and data experts.

overload resolution failure, narrowing conversion

I have a strange situation with vb 2005 regarding option strict that looks
like a compiler bug to me. Consider:

Dim f1 As New Font("Arial", 8.25)
Dim f2 As New Font("Arial", 8.25, FontStyle.Bold)

' f1 is ok with option strict on or off
' f2 is ok with strict on, but with off I get an overload resolution failure

The complete diagnostic is:

Overload resolution failed because no accessible 'New' can be called without
a narrowing conversion:
Public Sub New(familyName As String, emSize As Single, unit As
System.Drawing.GraphicsUnit)
: Argument matching parameter 'emSize' narrows from 'Double' to 'Single'.
Public Sub New(familyName As String, emSize As Single, unit As
System.Drawing.GraphicsUnit)
: Argument matching parameter 'unit' narrows from 'System.Drawing.FontStyle'
to 'System.Drawing.GraphicsUnit'.
Public Sub New(familyName As String, emSize As Single, style As
System.Drawing.FontStyle)
: Argument matching parameter 'emSize' narrows from 'Double' to 'Single'.

The following are also true:
Option Explicit is 'on'
Treat all warnings as errors is 'on'
Use if variable prior to assignment has notification 'none'
All other optional notifications are 'error'

It looks to me like the sense of the testing is backwards - it should
diagnose with strict on and allow with strict off. Additionally, it looks
like f1 and f2 should both succeed or both fail under the same compiler
settings/options since the complaint is about narrowing 8.25 from double to
single. FYI, one difference that may be in play is what you see with
intellisense. When you key in f1, you start with 13 available overloads, and
you end on 6. For f2, you start with 13 and end on 5.

Easy workarounds are available, namely using Csng() or use option strict.
Regardless, this looks like a vb compiler bug.

Jan 4 '08 #1
1 3563
"AMercer" <AM*****@discussions.microsoft.comschrieb
I have a strange situation with vb 2005 regarding option strict that
looks like a compiler bug to me. Consider:
Seems so. Fixed in VB 2008.
Armin
Jan 4 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Alexander Stippler | last post by:
Hi, I have got a question concerning the overload resolution rules of C++ and enumeration types. The following little test program illustrates the situation: enum { red, green, blue }; ...
7
by: Richard Hayden | last post by:
Hi, I have the following code for example: /**********************************/ #include <iostream> class C1 { public:
0
by: Eph0nk | last post by:
Hi, I get an overload resolution failed error (Overload resolution failed because no accessible 'New' can be called without a narrowing conversion), and I can't seem to find a lot of relevant...
5
by: Gang Zhang | last post by:
Hi, I have 2 overloaded functions as below: myfunc(byval val as Decimal) as string myfunc(byval val as String) as string When calling the function with a single like: dim num1 as single...
0
by: Cailin | last post by:
I am trying to make a connection with my SQL server DB, and I got this error message: "BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing...
2
by: jason | last post by:
Since going to framework 2.0 from 1.1, I'm getting error: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion: On line: Dim LogInfo As New...
2
by: sri | last post by:
class Base { public: virtual void f(int) { std::cout<<"base.f(int)\n";}; virtual void f(std::complex<double>) { std::cout<<"derived.f \n"; }; }; class Derived : public Base {
2
by: xtrigger303 | last post by:
Hi to all, I was reading Mr. Alexandrescu's mojo article and I've a hard time understanding the following. Let's suppose I have: //code struct A {}; struct B : A {};
9
by: sebastian | last post by:
I've simplified the situation quite a bit, but essentially I have something like this: struct foo { }; void bar( foo const & lhs, foo const & rhs )
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.