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

            Bug ID: 121031
           Summary: if condition misparsed as declaration in Objective C
                    method
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: objc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ats-gccbugs at offog dot org
                CC: iains at gcc dot gnu.org
  Target Milestone: ---

Created attachment 61836
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61836&action=edit
Minimised example

The attached example is minimised from Oolite's OOPriorityQueue.m. There are a
couple of cases in Oolite where GCC 15.1.0 is apparently misparsing a
straightforward if condition as a pointer declaration
(https://github.com/OoliteProject/oolite/pull/520) - adding brackets around the
LHS makes it happy.

Compiling with GCC 15.1.0 fails like this:

$ gcc -v -c ifparse.m 
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-pc-linux-gnu
Configured with: /src/devel/gcc/work/gcc-15.1.0/configure --prefix=/gar
--sysconfdir=/etc --localstatedir=/var --sharedstatedir=/var/com
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --enable-__cxa_atexit
--enable-threads=posix --enable-shared
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --with-local-prefix=/gar
--disable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.1.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /gar/packages/gcc-15.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/15.1.0/cc1obj
-quiet -v -iprefix
/gar/packages/gcc-15.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.0/ ifparse.m
-quiet -dumpbase ifparse.m -dumpbase-ext .m -mtune=generic -march=x86-64
-version -o /tmp/cccqBcCZ.s
GNU Objective-C (GCC) version 15.1.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 15.1.0, GMP version 6.3.0, MPFR version
4.2.2, MPC version 1.3.1, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/gar/packages/gcc-15.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory
"/gar/packages/gcc-15.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/15.1.0/include"
ignoring duplicate directory
"/gar/packages/gcc-15.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/15.1.0/include-fixed"
ignoring nonexistent directory
"/gar/packages/gcc-15.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /gar/packages/gcc-15.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.0/include

/gar/packages/gcc-15.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.0/include-fixed
 /gar/include
End of search list.
Compiler executable checksum: 7eea9bb219287c09feb0e71d34f602c8
ifparse.m:13:1: warning: class ‘OOPriorityQueue’ defined without specifying a
base class [-Wobjc-root-class]
   13 | - (void)removeObjectAtIndex:(int)i
      | ^
ifparse.m: In function ‘-[OOPriorityQueue removeObjectAtIndex:]’:
ifparse.m:15:13: error: unknown type name ‘_count’
   15 |         if (_count * 2 < _count)
      |             ^~~~~~
ifparse.m:15:22: error: expected identifier or ‘(’ before numeric constant
   15 |         if (_count * 2 < _count)
      |                      ^
ifparse.m:15:13: error: declaration in the controlling expression must have an
initializer
   15 |         if (_count * 2 < _count)
      |             ^~~~~~

Here's this example on Compiler Explorer: https://godbolt.org/z/5sfvxTbWe

It fails there with trunk and 15.1.0, and works with 14.3 and older versions.
  • [Bug objc/121031] New: if condit... ats-gccbugs at offog dot org via Gcc-bugs

Reply via email to