Problem with enums and std::max()

H

Hendrik Schober

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

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
 
M

mlimber

Hendrik said:
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
 
H

Hendrik Schober

mlimber said:
Hendrik said:
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

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top