public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35158]  New: g++ does not compile valid C++ for loops with -fopenmp
@ 2008-02-11  0:36 kugelfang at gentoo dot org
  2008-02-13 22:11 ` [Bug c++/35158] " manu at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kugelfang at gentoo dot org @ 2008-02-11  0:36 UTC (permalink / raw)
  To: gcc-bugs

The following C++ programm will not compile using current
either gcc-4.2.2 or gcc-4.3.0(svn):

  int main(int argc, char *argv[])
  {
    #pragma omp parallel for
    for (int i(0) ; i < 10 ; i++)
      ;

    return 0;
  }

The error messages for 'g++ -fopenmp -o foo foo.cc' are:

  foo.cc: In function 'int main(int, char**)':
  foo.cc:4: error: expected primary-expression before 'int'
  foo.cc:4: error: expected `;' before 'int'
  foo.cc:4: error: expected primary-expression before 'int'
  foo.cc:4: error: expected `;' before 'int'
  foo.cc:4: error: expected primary-expression before 'int'
  foo.cc:4: error: expected `)' before 'int'
  foo.cc:4: error: expected iteration declaration or initialization
  foo.cc:4: error: 'i' was not declared in this scope
  foo.cc:4: error: expected `;' before ')' token

The program compiles without error messages when I use 'g++ -o foo foo.cc'!


-- 
           Summary: g++ does not compile valid C++ for loops with -fopenmp
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kugelfang at gentoo dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
@ 2008-02-13 22:11 ` manu at gcc dot gnu dot org
  2008-08-06 20:15 ` manu at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-13 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2008-02-13 22:10 -------
Confirmed in GCC 4.3 revision 132291.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-02-13 22:10:56
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
  2008-02-13 22:11 ` [Bug c++/35158] " manu at gcc dot gnu dot org
@ 2008-08-06 20:15 ` manu at gcc dot gnu dot org
  2008-08-06 22:27 ` manu at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-06 20:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from manu at gcc dot gnu dot org  2008-08-06 20:14 -------
Reconfirmed in GCC 4.4


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.4.0 4.3.0
   Last reconfirmed|2008-02-13 22:10:56         |2008-08-06 20:14:08
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
  2008-02-13 22:11 ` [Bug c++/35158] " manu at gcc dot gnu dot org
  2008-08-06 20:15 ` manu at gcc dot gnu dot org
@ 2008-08-06 22:27 ` manu at gcc dot gnu dot org
  2008-08-10 21:48 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-06 22:27 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 603 bytes --]



------- Comment #3 from manu at gcc dot gnu dot org  2008-08-06 22:26 -------
CC Jakub,

Is this initialization allowed in OpenMP or not? I have a patch that handles
it, so we can either allow it or we can give an error such:

error: parenthesized initialization not allowed in OpenMP ‘for’


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (2 preceding siblings ...)
  2008-08-06 22:27 ` manu at gcc dot gnu dot org
@ 2008-08-10 21:48 ` jakub at gcc dot gnu dot org
  2008-08-10 22:19 ` danny dot dyk at tu-dortmund dot de
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-08-10 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-08-10 21:46 -------
This is invalid OpenMP code.
See 2.5.1 (in OpenMP 3.0, similar wording is in 2.5 standard too):

   init-expr   One of the following:
               var = lb
               integer-type var = lb
               random-access-iterator-type var = lb
               pointer-type var = lb

Therefore int i(0) isn't valid init-expr.  Having separate diagnostics for it
rather than just reporting a generic parse error might make some sense though.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (3 preceding siblings ...)
  2008-08-10 21:48 ` jakub at gcc dot gnu dot org
@ 2008-08-10 22:19 ` danny dot dyk at tu-dortmund dot de
  2008-08-10 22:30 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: danny dot dyk at tu-dortmund dot de @ 2008-08-10 22:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from danny dot dyk at tu-dortmund dot de  2008-08-10 22:17 -------
That means - contrary to popular knowledge - that OpenMP is not C++ compatible.
Fair enough! Just don't announce it as such, then.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (4 preceding siblings ...)
  2008-08-10 22:19 ` danny dot dyk at tu-dortmund dot de
@ 2008-08-10 22:30 ` jakub at gcc dot gnu dot org
  2008-08-10 22:50 ` danny dot dyk at tu-dortmund dot de
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-08-10 22:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-08-10 22:28 -------
No idea how do you infer that from this.
If you use #pragma omp for before a loop construct, there are many restrictions
you need to honor to have a valid OpenMP program, this is just one of them.
To list just some other is e.g. that the for condition must be present and be
iter_var < lb (or <=, >, >=), while generic C/C++ for can have any expression
there, there are restrictions on the increment expression as well (e.g. it has
to be addition or subtraction to the iteration var, while non-OpenMP for can
have any expression there, etc.).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (5 preceding siblings ...)
  2008-08-10 22:30 ` jakub at gcc dot gnu dot org
@ 2008-08-10 22:50 ` danny dot dyk at tu-dortmund dot de
  2008-08-10 22:51 ` manu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: danny dot dyk at tu-dortmund dot de @ 2008-08-10 22:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from danny dot dyk at tu-dortmund dot de  2008-08-10 22:49 -------
Applicable to a subset of C++ doesn't equal C++ compatibility.

I'm fine with OpenMP unable to successfully parallelise a majority of possible
for loops. It's quite understandable. However, instead of throwing error
messages it should keep these for loops singlethreaded and issue a warning.

G++ is a C++ compiler, not an OpenMP compiler. The -fopenmp switch should not
alter the perception of what is valid code and what not.

Now, is there any part in the OpenMP standard that forces a valid
implementation to bring all OpenMP directives to effect? Or is it OK to just
issue warning?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (6 preceding siblings ...)
  2008-08-10 22:50 ` danny dot dyk at tu-dortmund dot de
@ 2008-08-10 22:51 ` manu at gcc dot gnu dot org
  2008-08-11 13:16 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-10 22:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from manu at gcc dot gnu dot org  2008-08-10 22:50 -------
A patch was posted here:
http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00442.html

(I miss the patch tracker!!!)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (7 preceding siblings ...)
  2008-08-10 22:51 ` manu at gcc dot gnu dot org
@ 2008-08-11 13:16 ` jakub at gcc dot gnu dot org
  2008-08-20 16:38 ` manu at gcc dot gnu dot org
  2008-08-20 16:39 ` manu at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-08-11 13:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jakub at gcc dot gnu dot org  2008-08-11 13:14 -------
To answer c#7, that's what would (and does) happen for autoparallelization.
But OpenMP is explicit parallelization, if you don't preceede for (...; ...;
...) ... construct with #pragma omp {,parallel } for, nothing will warn nor
error on it.  But if you have the pragma there and request OpenMP pragmas to be
recognized, then the program must not only be valid C++ (or C or Fortran), but
also valid OpenMP code, so just warnings aren't appropriate.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (8 preceding siblings ...)
  2008-08-11 13:16 ` jakub at gcc dot gnu dot org
@ 2008-08-20 16:38 ` manu at gcc dot gnu dot org
  2008-08-20 16:39 ` manu at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-20 16:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from manu at gcc dot gnu dot org  2008-08-20 16:36 -------
Subject: Bug 35158

Author: manu
Date: Wed Aug 20 16:35:21 2008
New Revision: 139335

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139335
Log:
2008-08-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/35158
cp/   
        * parser.c (cp_parser_omp_for_loop): Handle parenthesized
        initializers.
testsuite/
        * g++.dg/gomp/pr35158.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr35158.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

* [Bug c++/35158] g++ does not compile valid C++ for loops with -fopenmp
  2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
                   ` (9 preceding siblings ...)
  2008-08-20 16:38 ` manu at gcc dot gnu dot org
@ 2008-08-20 16:39 ` manu at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-20 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from manu at gcc dot gnu dot org  2008-08-20 16:38 -------
Fixed in GCC 4.4


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35158


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

end of thread, other threads:[~2008-08-20 16:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11  0:36 [Bug c++/35158] New: g++ does not compile valid C++ for loops with -fopenmp kugelfang at gentoo dot org
2008-02-13 22:11 ` [Bug c++/35158] " manu at gcc dot gnu dot org
2008-08-06 20:15 ` manu at gcc dot gnu dot org
2008-08-06 22:27 ` manu at gcc dot gnu dot org
2008-08-10 21:48 ` jakub at gcc dot gnu dot org
2008-08-10 22:19 ` danny dot dyk at tu-dortmund dot de
2008-08-10 22:30 ` jakub at gcc dot gnu dot org
2008-08-10 22:50 ` danny dot dyk at tu-dortmund dot de
2008-08-10 22:51 ` manu at gcc dot gnu dot org
2008-08-11 13:16 ` jakub at gcc dot gnu dot org
2008-08-20 16:38 ` manu at gcc dot gnu dot org
2008-08-20 16:39 ` manu at gcc dot gnu dot 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).