473,748 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internal Compiler Error // Stupid Standards?

Don't try to solve the problem. I've found a way -- around or fixing it. I'm
just curious as to whether this is Microsoft's problem in their compiler or
if there's a standard saying this is to be true (not necessarily an internal
compiler error, but still an error)

This may just a bit OT, but I decided to post it here instead of Microsoft
because my question is more directed towards standards...

Of course, any other day I would have been on my Linux computer with GCC,
but today I didn't have that option. I have the following function. I tried
to standarize it (CList => vector) but just about every function is
different. Basically, type T and A are about the same (the type of the
vector). The functions are somewhat self explanatory... A POSITION is
basically an index; not exactly, but for our purposes we will say that it
is...

template <class T, class A>
CList<T, A>& copyList(CList< T, A>& mod, const CList<T, A>& orig)
{
POSITION curpos;

// Make sure mod is empty
while (!mod.IsEmpty() )
mod.RemoveHead( );
#pragma warning(disable :4706)
if (!(curpos = orig.GetHeadPos ition()))

return mod;
else
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

orig.GetNext(cu rpos);
while (curpos)
{
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));
orig.GetNext(cu rpos);
};

// Do one more...
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));
orig.GetNext(cu rpos);
return mod;
}

I get the following error:
fatal error C1001: INTERNAL COMPILER ERROR

Trying to compile with option /Bd (which is supposed to help you locate
where the internal error occurs) ends up crashing the compiler, instead of
yielding a C1001. I've found out that the problem lies in the #pragma
warning(disable :4706).

By placing the #pragma warning(disable :4706) outside of the template, the
template works fine. Is there a practical reason for this? Or is it just one
of the many bugs that M$ produces every year...

Microsoft Visual C++ 6.0 using MFC
------------------------------------------

On an unrelated note, actually, I have one more question about ANSI
standards. In the same block of code, there is a messy line (which you
probably all yelled at when you read it) which reads

mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

(similar ones follow)

Of course nobody likes to use a const_cast. The problem was that I was
getting a warning, stating that a non-standard extention was being used. I
try to make my programs as standard as possible. When compiling the (I
thought) pratical line:

mod.AddHead(ori g.GetAt(curpos) );

I got the following warning:

c:\program files\microsoft visual
studio\myprojec ts\digitaldarkr oom\stdafx.h(53 ) : warning C4239: nonstandard
extension used : 'argument' : conversion from 'class CFilter' to 'class
CFilter &'
A reference that is not to 'const' cannot be bound to a non-lvalue

That line struck me: "A reference that is not to 'const' cannot be bound to
a non-lvalue." Why exactly is that? It seems like it's just another
compilcation in the midst of C++... I don't see any practical purpose for
not being able to bind a non-lvalue to reference to a non-const. In fact, it
almost makes more sense. Obviously the line a = 4 is legal, but taking out
the reference, it is exactly the same thing. A non-const (but not a
reference) is being bound by a non-lvalue (obviously you can't write 4 = a).
Thus, I was forced to "de-const" the paramter to make it standardized.
Surely, the line

mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

is much uglier, but at least it's standardized. Certainly nobody ever likes
to run with const_casts in their programs. It's almost as bad as a
reinterpret_cas t and completely oversteps the point of a type-strict
language. Of course there are other ways around it, too, but this was the
easiest to code, in my opinion.

So why exactly is it there? Makes absolutely no sense to me...

-- Matt
Jul 22 '05 #1
7 2676

"Matthew Del Buono" <Ma******@nospa m.com> wrote in message
news:sQfoc.1264 8$Lm3.5825@lake read04...
Don't try to solve the problem. I've found a way -- around or fixing it. I'm just curious as to whether this is Microsoft's problem in their compiler or if there's a standard saying this is to be true (not necessarily an internal compiler error, but still an error)

This may just a bit OT, but I decided to post it here instead of Microsoft
because my question is more directed towards standards...

Of course, any other day I would have been on my Linux computer with GCC,
but today I didn't have that option. I have the following function. I tried to standarize it (CList => vector) but just about every function is
different. Basically, type T and A are about the same (the type of the
vector). The functions are somewhat self explanatory... A POSITION is
basically an index; not exactly, but for our purposes we will say that it
is...

template <class T, class A>
CList<T, A>& copyList(CList< T, A>& mod, const CList<T, A>& orig)
{
POSITION curpos;

// Make sure mod is empty
while (!mod.IsEmpty() )
mod.RemoveHead( );
#pragma warning(disable :4706)
if (!(curpos = orig.GetHeadPos ition()))

return mod;
else
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

orig.GetNext(cu rpos);
while (curpos)
{
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));
orig.GetNext(cu rpos);
};

// Do one more...
mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));
orig.GetNext(cu rpos);
return mod;
}

I get the following error:
fatal error C1001: INTERNAL COMPILER ERROR

Trying to compile with option /Bd (which is supposed to help you locate
where the internal error occurs) ends up crashing the compiler, instead of
yielding a C1001. I've found out that the problem lies in the #pragma
warning(disable :4706).

By placing the #pragma warning(disable :4706) outside of the template, the
template works fine. Is there a practical reason for this? Or is it just one of the many bugs that M$ produces every year...
No idea, but the effect of pragmas is completely compiler dependent and if
MS want to make it a requirement that you put this pragma outside of any
templates they can.

Microsoft Visual C++ 6.0 using MFC
------------------------------------------

On an unrelated note, actually, I have one more question about ANSI
standards. In the same block of code, there is a messy line (which you
probably all yelled at when you read it) which reads

mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

(similar ones follow)

Of course nobody likes to use a const_cast. The problem was that I was
getting a warning, stating that a non-standard extention was being used. I
try to make my programs as standard as possible.
Well why in God's name are you using CList? Use std::list instead (not
std::vector), its both standard and better designed. Obviously this will
mean some code rewriting.
When compiling the (I
thought) pratical line:

mod.AddHead(ori g.GetAt(curpos) );

I got the following warning:

c:\program files\microsoft visual
studio\myprojec ts\digitaldarkr oom\stdafx.h(53 ) : warning C4239: nonstandard extension used : 'argument' : conversion from 'class CFilter' to 'class
CFilter &'
A reference that is not to 'const' cannot be bound to a non-lvalue

That line struck me: "A reference that is not to 'const' cannot be bound to a non-lvalue." Why exactly is that? It seems like it's just another
compilcation in the midst of C++... I don't see any practical purpose for
not being able to bind a non-lvalue to reference to a non-const. In fact, it almost makes more sense.
It's alleged that the possibility of binding a temporary (or non-lvalue) to
a non-const reference is confusing. This was feedback during the
developement of C++ according to Bjarne Stroustrup (there's a post in the
archives of comp.lang.c++ to that effect, maybe you could find it).

I have my doubts but it not usually a problem in well written code, so its
not something that bothers me too much. It does bother me that some
compilers don't enforce this rule correctly, that does lead to confusion.
Obviously the line a = 4 is legal, but taking out
the reference, it is exactly the same thing. A non-const (but not a
reference) is being bound by a non-lvalue (obviously you can't write 4 = a). Thus, I was forced to "de-const" the paramter to make it standardized.
Surely, the line

mod.AddHead(con st_cast<CList<T , A>&>(orig).GetA t(curpos));

is much uglier, but at least it's standardized. Certainly nobody ever likes to run with const_casts in their programs. It's almost as bad as a
reinterpret_cas t and completely oversteps the point of a type-strict
language. Of course there are other ways around it, too, but this was the
easiest to code, in my opinion.
What is the type of A in this case? If you made A a const reference I
believe the code should compile without the const_cast.

So why exactly is it there? Makes absolutely no sense to me...

-- Matt

Jul 22 '05 #2
"Matthew Del Buono" <Ma******@nospa m.com> wrote in message
news:sQfoc.1264 8$Lm3.5825@lake read04...
Don't try to solve the problem. I've found a way -- around or fixing it. I'm just curious as to whether this is Microsoft's problem in their compiler or if there's a standard saying this is to be true (not necessarily an internal compiler error, but still an error)

This may just a bit OT, but I decided to post it here instead of Microsoft
because my question is more directed towards standards...

Of course, any other day I would have been on my Linux computer with GCC,
but today I didn't have that option. I have the following function. I tried to standarize it (CList => vector) but just about every function is
different. Basically, type T and A are about the same (the type of the
vector). The functions are somewhat self explanatory... A POSITION is
basically an index; not exactly, but for our purposes we will say that it
is...

template <class T, class A>
CList<T, A>& copyList(CList< T, A>& mod, const CList<T, A>& orig)
{
POSITION curpos;

// Make sure mod is empty
while (!mod.IsEmpty() )
mod.RemoveHead( );
#pragma warning(disable :4706)
if (!(curpos = orig.GetHeadPos ition()))
The compiler warning which you disables is "assignment within conditional
expression".
Are you 100% sure you aren't accidently using the assignment operator (=)
instead of the comparison operator (==) ?


By placing the #pragma warning(disable :4706) outside of the template, the
template works fine. Is there a practical reason for this? Or is it just one of the many bugs that M$ produces every year...


You can turn off warnings by issuing pragmas. I think it's useful, but I do
find out first what the warning's about. If I decide that the code is fine,
then I'll just add a pragma. :)

/Carl
Jul 22 '05 #3
"Matthew Del Buono" <Ma******@nospa m.com> wrote in message news:<sQfoc.126 48$Lm3.5825@lak eread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myprojec ts\digitaldarkr oom\stdafx.h(53 ) : warning C4239: nonstandard
extension used : 'argument' : conversion from 'class CFilter' to 'class
CFilter &'
A reference that is not to 'const' cannot be bound to a non-lvalue

That line struck me: "A reference that is not to 'const' cannot be bound to
a non-lvalue." Why exactly is that?


int f() { return 42; }
void increment( int& v ) { ++v; }
increment(f());

What is incremented? Where does the result go?

Regards,
Michiel Salters
Jul 22 '05 #4
Michiel Salters wrote:
int f() { return 42; }
void increment( int& v ) { ++v; }
increment(f());

What is incremented? Where does the result go?


a temporary containing 42 could be incremented, and the result then be
dropped. And everything would be optimized away in the end.

What's wrong with allowing it*? There is no ambiguity.
Jul 22 '05 #5
Michiel Salters wrote:
"Matthew Del Buono" <Ma******@nospa m.com> wrote in message news:<sQfoc.126 48$Lm3.5825@lak eread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myproj ects\digitaldar kroom\stdafx.h( 53) : warning C4239: nonstandard
extension used : 'argument' : conversion from 'class CFilter' to 'class
CFilter &'
A reference that is not to 'const' cannot be bound to a non-lvalue

That line struck me: "A reference that is not to 'const' cannot be bound to
a non-lvalue." Why exactly is that?

int f() { return 42; }
void increment( int& v ) { ++v; }
increment(f());

What is incremented? Where does the result go?


I guess the temporary from f() would be incrememented, but that'll just "disappear" .

The warning is complaining about passing a temporary into a function that could
possibly changes its value (due to a non-const reference).

If you changed the increment method to return the incremented value, you'd be
ok. Or in the case of the warning, whatever you're trying to pass a CFilter
into... make it "const CFilter &".

int f() { return 42; }
const int increment(const int & v) { return(v++); }
int value = increment(f());


Regards,
Michiel Salters

Jul 22 '05 #6
"Matthew Del Buono" <Ma******@nospa m.com> wrote in message news:<sQfoc.126 48$Lm3.5825@lak eread04>...
[snip]
Trying to compile with option /Bd (which is supposed to help you locate
where the internal error occurs) ends up crashing the compiler, instead of
yielding a C1001. I've found out that the problem lies in the #pragma
warning(disable :4706).

By placing the #pragma warning(disable :4706) outside of the template, the
template works fine. Is there a practical reason for this? Or is it just one
of the many bugs that M$ produces every year...


Urm. Well, it's a tad off topic, and also a tad sarcastic and snide.
But I've already got today's headache, so...

C1001 is the "I'm in trouble but don't know how to get out" message.
Someplace, a "sensibilit y" check has failed, indicating that something
has gone badly wrong. But the compiler can't pinpoint it, and has
no way of correcting it. Generally, in such situations, anything
output after that is mighty suspect at best.

Dealing with it can be frustrating. It can happen in perfectly correct
and legal code, even according to MS's definition of those words. Or
it can happen due to a real error in the code, and indicate that the
compiler has misdiagnosed something, or failed to correctly handle
the error condition. For example, it might be that there is some
bug in the compiler that does not correctly deal with some category
of syntax errors, in some set of conditions. Or there may be some
poorly mapped limitation of the compiler, say depth of this-n-that
combined with width of that-n-this, etc., that only shows up when
you skate close enough to the edge on several things.

About all you can do is nudge and poke your code till the error goes
away.
Socks
Jul 22 '05 #7

"J. Andrew MacDonald" <am******@caris .com> wrote in message
news:E1******** *************@u rsa-nb00s0.nbnet.nb .ca...
Michiel Salters wrote:
"Matthew Del Buono" <Ma******@nospa m.com> wrote in message news:<sQfoc.126 48$Lm3.5825@lak eread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myproj ects\digitaldar kroom\stdafx.h( 53) : warning C4239: nonstandardextension used : 'argument' : conversion from 'class CFilter' to 'class
CFilter &'
A reference that is not to 'const' cannot be bound to a non-lvalue
That line struck me: "A reference that is not to 'const' cannot be bound toa non-lvalue." Why exactly is that?

int f() { return 42; }
void increment( int& v ) { ++v; }
increment(f());

What is incremented? Where does the result go?


I guess the temporary from f() would be incrememented, but that'll just

"disappear" .
The warning is complaining about passing a temporary into a function that could possibly changes its value (due to a non-const reference).

If you changed the increment method to return the incremented value, you'd be ok. Or in the case of the warning, whatever you're trying to pass a CFilter into... make it "const CFilter &".

int f() { return 42; }
const int increment(const int & v) { return(v++); }
int value = increment(f());


Regards,
Michiel Salters


Ah, okay, I get it. Honestly I didn't care about the pass-back from the
value. So I guess it's that I didn't properly understand its wording. Thanks
for explaining it.

-- Matt
Jul 22 '05 #8

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

Similar topics

6
8624
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to build my gui and dll projects, whose project, workspace, source files all resided on network drive mapped to H. The H mapping,
30
2953
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and eventually, here is what happens. Anyone ever experience anything similar. This or similar untrackable problems happen to me whenever I write a large class... anyone have had similar experiences??? make
6
1976
by: Rajesh.S | last post by:
some more info... >-----Original Message----- >I built a VC++.Net project as a dll and >included it as a reference in a c# project. >When I call a c++ function from the csharp >project I get internal compiler error. > >The function in the c++ dll got the signature >void __gc *CInitialContext::Lookup(char *)
16
2853
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...) Oh, I forgot to list the error messages; I would be delighted if someone could explain how to deduce which line number in which file is the one that the VC compiler cannot handle. Actually I'm using C#, but the only post I could find about...
1
13249
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem,
4
3323
by: David Sworder | last post by:
Consider the following line of code (it's not important what it does): resp.DocItem=Relations.SelectDocItems_BySearchString(req.SearchPhrase); It turns out that this line is in error. The property 'DocItem' should be 'DocItems.' The problem is that instead of notifying me of where the problem has occurred, the compiler just crashes with an "internal error" (see bottom of this message). Now if I were to write: ...
1
1766
by: pj | last post by:
Oh, I forgot to list the error messages; I would be delighted if someone could explain how to deduce which line number in which file is the one that the VC compiler cannot handle. Actually I'm using C#, but the only post I could find about INTERNAL ERROR had an annotation saying the problem is the vc compiler. Unfortunately it was from a year ago and had no resolution. What do other people do when they hit compiler bugs ? Perhaps you...
6
2726
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep facing the same problem with many of them: I keep getting errors such as: ....\WinUser.h(8028): fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701)
10
9002
by: LZXIA | last post by:
Compiling... overlaod.cpp d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information Error executing cl.exe.
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.