public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98126] New: -Wsequence-point is non-linear for certain cases
@ 2020-12-03 17:47 mpolacek at gcc dot gnu.org
  2020-12-03 22:14 ` [Bug c++/98126] " mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-03 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-07 17:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 17:47 [Bug c++/98126] New: -Wsequence-point is non-linear for certain cases mpolacek at gcc dot gnu.org
2020-12-03 22:14 ` [Bug c++/98126] " mpolacek at gcc dot gnu.org
2020-12-07 16:56 ` cvs-commit at gcc dot gnu.org
2020-12-07 17:00 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).