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

Problem with enums and std::max()

Hi,

consider this:

#include <algorithm>

enum X { foo, bar };

int main()
{
std::max( foo, bar );
return 0;
}

GCC 3.3.5 (with Dinkumware's std lib) warns that a reference
to a local object is returned in the above code. Neither VC8
nor XCode2's GCC (both with Dinkumware, too) complain about
this code. Am I right in supposing that this is simply a bug
in GCC 3.3.5?

TIA,

Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
Nov 21 '06 #1
2 2041
Hendrik Schober wrote:
consider this:

#include <algorithm>

enum X { foo, bar };

int main()
{
std::max( foo, bar );
return 0;
}

GCC 3.3.5 (with Dinkumware's std lib) warns that a reference
to a local object is returned in the above code. Neither VC8
nor XCode2's GCC (both with Dinkumware, too) complain about
this code. Am I right in supposing that this is simply a bug
in GCC 3.3.5?
Likely. EDG, VC6, and MINGW (gcc version something-or-other at
Dinkumware.com) don't complain either.

Cheers! --M

Nov 21 '06 #2
mlimber <ml*****@gmail.comwrote:
Hendrik Schober wrote:
consider this:
[...] Am I right in supposing that this is simply a bug
in GCC 3.3.5?

Likely. EDG, VC6, and MINGW (gcc version something-or-other at
Dinkumware.com) don't complain either.
Thanks for looking into this!
Cheers! --M
Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
Nov 27 '06 #3

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

Similar topics

5
by: PengYu.UT | last post by:
Hi, Would you please let me know where max and min int are defined in C++? Best wishes, Peng
11
by: Angus | last post by:
Hello I am following the exercises in Accelerated C++ Practical Programming by Example and when use: using std::max; I get these compile errors in MS Visual C++ v6 error C2039: 'max' : is...
41
by: Gary Wessle | last post by:
Hi often I need to read numbers and only keep the highest or lowest. so I do something like int uLimit = 0; int lLimit = 999999999999; //hoping the compiler will not complain uLimit =...
10
by: JDT | last post by:
Hi, Can someone provide me an example that uses std::max_element() (probablly the predicate version) to return the max "absolute" integer in a vector? Your help is much appreciated. Tony ...
13
by: John Doe | last post by:
If I include <cmathand write std::abs in my program I get: gcc -MD -o /home/bla/c++/.build/generator.o -c generator.cpp generator.cpp: In function 'int main(int, char**)': generator.cpp:206:...
4
by: Hora | last post by:
Hi Guys I'm reading Andrew Koenig and Barbara E. Moo 's book, Accelerated C++. It's the best works for newbie I ever read. The way the authors introduce the language is very interesting. In...
8
by: Phil Endecott | last post by:
Dear Experts, I'm surprised to find that std::max doesn't work (i.e. won't compile) if the arguments are not of exactly the same type, e.g. one is a short and the other is a long: #include...
17
by: Adem24 | last post by:
What is the best way to get the minimum value and the maximum value an integral POD can hold without using any external definitions like INT_MIN, INT_MAX etc.? The type (short, int, long, etc.)...
7
by: abir | last post by:
In my program i wan to use a certain type as both type T1 (usually non-pod) and also T2 (usually size_t) so an union like this doesn't work template<typename T> union utype{ T v_;...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.