473,410 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 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 3686
"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 )
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.