473,395 Members | 1,458 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,395 software developers and data experts.

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.GetHeadPosition()))

return mod;
else
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));

orig.GetNext(curpos);
while (curpos)
{
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));
orig.GetNext(curpos);
};

// Do one more...
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));
orig.GetNext(curpos);
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(const_cast<CList<T, A>&>(orig).GetAt(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(orig.GetAt(curpos));

I got the following warning:

c:\program files\microsoft visual
studio\myprojects\digitaldarkroom\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(const_cast<CList<T, A>&>(orig).GetAt(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_cast 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 2648

"Matthew Del Buono" <Ma******@nospam.com> wrote in message
news:sQfoc.12648$Lm3.5825@lakeread04...
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.GetHeadPosition()))

return mod;
else
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));

orig.GetNext(curpos);
while (curpos)
{
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));
orig.GetNext(curpos);
};

// Do one more...
mod.AddHead(const_cast<CList<T, A>&>(orig).GetAt(curpos));
orig.GetNext(curpos);
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(const_cast<CList<T, A>&>(orig).GetAt(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(orig.GetAt(curpos));

I got the following warning:

c:\program files\microsoft visual
studio\myprojects\digitaldarkroom\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(const_cast<CList<T, A>&>(orig).GetAt(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_cast 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******@nospam.com> wrote in message
news:sQfoc.12648$Lm3.5825@lakeread04...
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.GetHeadPosition()))
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******@nospam.com> wrote in message news:<sQfoc.12648$Lm3.5825@lakeread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myprojects\digitaldarkroom\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******@nospam.com> wrote in message news:<sQfoc.12648$Lm3.5825@lakeread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myprojects\digitaldarkroom\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******@nospam.com> wrote in message news:<sQfoc.12648$Lm3.5825@lakeread04>...
[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 "sensibility" 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*********************@ursa-nb00s0.nbnet.nb.ca...
Michiel Salters wrote:
"Matthew Del Buono" <Ma******@nospam.com> wrote in message news:<sQfoc.12648$Lm3.5825@lakeread04>...
I got the following warning:

c:\program files\microsoft visual
studio\myprojects\digitaldarkroom\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
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...
30
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...
6
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...
16
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...)...
1
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...
4
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...
1
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...
6
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...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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...

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.