public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: corey taylor <corey.taylor@gmail.com>
To: Steve deRosier <derosier@pianodisc.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: differences w/ enum in for loop between 3.3.2 and 3.4.3
Date: Wed, 06 Jul 2005 20:40:00 -0000	[thread overview]
Message-ID: <2e393d080507061340d16160c@mail.gmail.com> (raw)
In-Reply-To: <42CC41DD.8060605@pianodisc.com>

Steve,

  You are correct about the C++ conflict.

  Look at the 4th bullet in the C/Objective-C/C++ section:

  http://gcc.gnu.org/gcc-3.4/changes.html

corey

On 7/6/05, Steve deRosier <derosier@pianodisc.com> wrote:
> Perhaps this is now against standard ISO C++ now, but in g++ 3.3.2, the following code compiled (snipped and adjusted of course):
> 
> class whatever
> {
>   private:
>     typedef enum { BUFF_LEFT=0, BUFF_RIGHT=1, BUFF_SIZE=2 } eBuffSide;
> }
> 
> void whatever::function( void )
> {
>   for( eBuffSide i = BUFF_LEFT; i <= BUFF_RIGHT; (int(i))++ )
>   {
>     function2( i )
>     ...
>   }
> }
> 
> Now with 3.4.3 I get an error:
> "error: ISO C++ forbids cast to non-reference type used as lvalue"
> 
> What gives?
> 
> Removing the cast gives me an error about not being able to find a postfix operator++.  To make this compile under 3.4.3 I have to code as:
> 
>   for( int i = BUFF_LEFT; i <= BUFF_RIGHT; i++ )
>   {
>     function2( eBuffSide(i) )
>     ...
>   }
> 
> Is there a better way to do this?  (And no, I don't want to make eBuffSide into a class of its own w/ proper operator overloading, it is just intended to be a class-scope named constant.)
> 
> - Steve
>

      reply	other threads:[~2005-07-06 20:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-06 20:33 Steve deRosier
2005-07-06 20:40 ` corey taylor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e393d080507061340d16160c@mail.gmail.com \
    --to=corey.taylor@gmail.com \
    --cc=derosier@pianodisc.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).