This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

non-lvalue error from asm expression when optimizing



hi -

For a recent cvs version of g++ (2.96 20000330 on i686-pc-linux-gnu),
the following input gets an error if -O is used:

--------------------------------------------------------------------
class ACE_INET_Addr
{
public:
  virtual ~ACE_INET_Addr (void) {}
  short get_port_number (void) const;
  virtual unsigned hash (void) const;
  virtual void set_addr ();
};


inline short
ACE_INET_Addr::get_port_number (void) const
{
  return 
     (__extension__							      
      ({ register unsigned short int __v;				      
	   __asm__ __volatile__ ("rorw $8, %w0"				      
				 : "=r" (__v)				      
				 : "0" ((unsigned short int) (0))	      
				 : "cc");				      
	 __v; }))
    ;
}

inline unsigned 
ACE_INET_Addr::hash (void) const
{
  return get_port_number ();
}

void
ACE_INET_Addr::set_addr ()
{
}

--------------------------------------------------------------------


$ ./cc1plus -quiet -O egcsbug14.cc 
egcsbug14.cc: In method `unsigned int ACE_INET_Addr::hash () const':
egcsbug14.cc:20: non-lvalue in assignment


The error goes away if the -O switch is left off.


(The asm expression in the above comes from expanding the ntohs macro
in glibc 2.1.2; i've appended a version of the above test case with
that macro left intact.)

thanks,
sss


#include <netinet/in.h>

class ACE_INET_Addr
{
public:
  virtual ~ACE_INET_Addr (void) {}
  short get_port_number (void) const;
  virtual unsigned hash (void) const;
  virtual void set_addr ();
};


inline short
ACE_INET_Addr::get_port_number (void) const
{
  return ntohs (0);
}

inline unsigned 
ACE_INET_Addr::hash (void) const
{
  return get_port_number ();
}

void
ACE_INET_Addr::set_addr ()
{
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]