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

            Bug ID: 98126
           Summary: -Wsequence-point is non-linear for certain cases
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This script generates C++ programs that show that -Wsequence-point exhibits
non-linear behavior:

#!/bin/bash
n=$1

printf "struct T { bool operator==(const T &ot) const; };
struct C {
  bool operator==(const C &ot) const {
    return\n"
for i in $(seq $n); do printf "      t$i == ot.t$i &&\n"; done
printf "      true; 
  }
"
for i in $(seq $n); do printf "  T t$i;\n"; done
printf "};\n"

$ ./gen.sh 100 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 0.60
$ ./gen.sh 200 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 4.50
$ ./gen.sh 300 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 14.62
$ ./gen.sh 400 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 34.46
$ ./gen.sh 500 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 67.27
$ ./gen.sh 600 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 117.33
$ ./gen.sh 700 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 179.78
$ ./gen.sh 800 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
real 278.54

Note that
$ ./gen.sh 800 > gen.cc && time -p ./cc1plus -quiet -fsyntax-only -Wall gen.cc
-Wno-sequence-point
real 0.14

Reply via email to