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

            Bug ID: 78045
           Summary: Parsing error when creating temporary object with
                    space in type name (unsigned int)
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamespharvey20 at gmail dot com
  Target Milestone: ---

For test code comparisons where the expected value can be constructed as a
temporary, I've been doing so.  This has really been for classes, but when I
tried it for `unsigned int` I ran into this bug.

In this test case, `i` is of course a substitute for the function being tested,
and `j` is the expected value.  This compiles and works fine:

   int main() {
      const int i{0};
      if(i != int{0}) {
         throw false;
      }
   }

Changing to an `unsigned int` fails:

   ...const unsigned int i{0};
      if(i != unsigned int{0})) {...

Giving:

   mine.cpp: In function ‘int main()’:
   mine.cpp:4:12: error: expected primary-expression before ‘unsigned’
       if(i != unsigned int{0}) {
               ^~~~~~~~
   mine.cpp:4:12: error: expected ‘)’ before ‘unsigned’

Unless the c++11 standard dictates only single word types may be made using
temporaries using initialization braces, I think the space is tripping up the
parsing.

Reply via email to