https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009

            Bug ID: 95009
           Summary: decltype of increment or decrement bitfield
                    expressions are wrong and causes assembler errors.
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: okannen at gmail dot com
  Target Milestone: ---

This bug exists since gcc version 6

The code bellow should not compile:

#include <type_traits>

  struct A
    {
    int i:31;
    };

  A a;

  //I am not sure the standard require that (a.i) and ++a.i have the same type.
  static_assert(!std::is_same_v <decltype ((a.i)), decltype(++a.i)>);
                          //      int&               int:31&

  //but I do believe that decltype(a.i+=1) and decltype(++a.i) shall have the
same type
  static_assert(!std::is_same_v <decltype ((a.i+=1)), decltype(++a.i)>);
                         //                int&            int:31&

[expr.pre.incr]/1 "The expression ++x is equivalent to x+=1."

  Actualy those weird "int:N" types cause a lot of trouble. This code cause  
assembler error:

  //test.cpp
  struct A{
        int i:31;
        };

  template <class T>
  void f(){ 
        }

  int main(){
        A a;
        f<decltype(a.i+=1)>();
        f<decltype(++a.i)>();
        return 0;
        }

`c++ test.cpp` outputs:
/tmp/ccTayNZZ.s: Assembler messages:
/tmp/ccTayNZZ.s:43: Error: symbol `_Z1fIRiEvv' is already defined

Reply via email to