public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27746]  New: ICE on openmp code when using _Pragma from macro
@ 2006-05-24  1:46 bowie dot owens at csiro dot au
  2006-05-24  1:47 ` [Bug c++/27746] " bowie dot owens at csiro dot au
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: bowie dot owens at csiro dot au @ 2006-05-24  1:46 UTC (permalink / raw)
  To: gcc-bugs

Using gcc 4.2 from SVN:

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/local_scratch/owe043/gcc_svn
Thread model: posix
gcc version 4.2.0 20060523 (experimental)

I get an ICE when when compiling (g++ -fopenmp omp.cc) the following program:

#define parallel_for _Pragma("omp parallel for") for
#define parallel _Pragma("omp parallel")
int
main()
{
        parallel {
        }

        parallel_for (int i = 0; i < 1000; ++i) {
        }

        return 0;
}


-- 
           Summary: ICE on openmp code when using _Pragma from macro
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bowie dot owens at csiro dot au
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
@ 2006-05-24  1:47 ` bowie dot owens at csiro dot au
  2006-05-24  3:08 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bowie dot owens at csiro dot au @ 2006-05-24  1:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bowie dot owens at csiro dot au  2006-05-24 01:47 -------
Created an attachment (id=11502)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11502&action=view)
c++ file which causes ICE


-- 


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


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

* [Bug c++/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
  2006-05-24  1:47 ` [Bug c++/27746] " bowie dot owens at csiro dot au
@ 2006-05-24  3:08 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:10 ` [Bug c/27746] " pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-05-24 03:08 -------
The ICE:
t1.cc:9: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The backtrace:
#0  0x90128b54 in abort ()
#1  0x00b6a898 in _cpp_backup_tokens (pfile=0x43805200, count=2) at
../../libcpp/macro.c:1206
#2  0x00b62ce4 in do_pragma (pfile=0x43805200) at
../../libcpp/directives.c:1321
#3  0x00b640fc in destringize_and_run (pfile=0x43805200, in=0x2) at
../../libcpp/directives.c:1508
#4  0x00b6ab38 in builtin_macro (pfile=0x43805200, node=0x434e6290) at
../../libcpp/macro.c:295
#5  0x00b6b990 in cpp_get_token (pfile=0x43805200) at ../../libcpp/macro.c:784
#6  0x00296038 in c_lex_with_flags (value=0xd410bc, loc=0xd410c0,
cpp_flags=0xd410b6 "?????????????B") at ../../gcc/c-lex.c:340
#7  0x00137034 in cp_lexer_get_preprocessor_token (lexer=0x434e86c0,
token=0xd410b4) at ../../gcc/cp/parser.c:394
#8  0x00136cd4 in cp_lexer_new_main () at ../../gcc/cp/parser.c:295
#9  0x0013a630 in cp_parser_new () at ../../gcc/cp/parser.c:2478
#10 0x0015d444 in c_parse_file () at ../../gcc/cp/parser.c:19140
#11 0x002a79c0 in c_common_parse_file (set_yydebug=0) at
../../gcc/c-opts.c:1164
#12 0x00540260 in compile_file () at ../../gcc/toplev.c:999
#13 0x00542b3c in do_compile () at ../../gcc/toplev.c:1970


-- 


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


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

* [Bug c/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
  2006-05-24  1:47 ` [Bug c++/27746] " bowie dot owens at csiro dot au
  2006-05-24  3:08 ` pinskia at gcc dot gnu dot org
@ 2006-05-24  3:10 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:24 ` [Bug preprocessor/27746] " pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-05-24 03:10 -------
C also has the same issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |c


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (2 preceding siblings ...)
  2006-05-24  3:10 ` [Bug c/27746] " pinskia at gcc dot gnu dot org
@ 2006-05-24  3:24 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:24 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-05-24 03:24 -------
(In reply to comment #4)
> Anyways here is a non openmp testcase that fails currently but it ICEs
> differently:

And I am going to file a different bug about that.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (3 preceding siblings ...)
  2006-05-24  3:24 ` [Bug preprocessor/27746] " pinskia at gcc dot gnu dot org
@ 2006-05-24  3:24 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:29 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-05-24 03:23 -------
Here is a reduced testcase:
#define parallel _Pragma("omp parallel")
int
main()
{
#pragma omp parallel
{}
}

----
The question is does macros allow to stuff in #pragmas.
I want to say yes.

Anyways here is a non openmp testcase that fails currently but it ICEs
differently:
#define push _Pragma ("pack(push)")
#define push1 _Pragma ("pack(push)")

push1


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |preprocessor
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-05-24 03:23:55
               date|                            |


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (4 preceding siblings ...)
  2006-05-24  3:24 ` pinskia at gcc dot gnu dot org
@ 2006-05-24  3:29 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:34 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-05-24 03:29 -------
(In reply to comment #4)
> The question is does macros allow to stuff in #pragmas.
> I want to say yes.

I changed my mind, no it should not be except for some cases.
Or at least the documented ones.  I don't even think this change in the
behavior of Pragmas are documented.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (5 preceding siblings ...)
  2006-05-24  3:29 ` pinskia at gcc dot gnu dot org
@ 2006-05-24  3:34 ` pinskia at gcc dot gnu dot org
  2006-05-24  3:42 ` bowie dot owens at csiro dot au
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-05-24 03:33 -------
I should note this is accepted with -save-temps so the preprocessor is doing
the correct thing at least to a point.  I bet PR 27747 and 27748 are really all
the same issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |27747, 27748
              nThis|                            |


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (6 preceding siblings ...)
  2006-05-24  3:34 ` pinskia at gcc dot gnu dot org
@ 2006-05-24  3:42 ` bowie dot owens at csiro dot au
  2006-05-24  3:45 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bowie dot owens at csiro dot au @ 2006-05-24  3:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from bowie dot owens at csiro dot au  2006-05-24 03:42 -------
I found out about _Pragma from the following page (at the bottom):

http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Function-Attributes.html

While it is not essential behaviour to allow _Pragma's to be generated from
macros, there are cases where it would be very useful. In my case I would
really like to be able to control the OpenMP directives that get included at a
fine grained level without littering my code with #ifdef's.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (7 preceding siblings ...)
  2006-05-24  3:42 ` bowie dot owens at csiro dot au
@ 2006-05-24  3:45 ` pinskia at gcc dot gnu dot org
  2006-05-25 12:29 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-24  3:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-05-24 03:45 -------
(In reply to comment #8)
> I found out about _Pragma from the following page (at the bottom):
You can work around this bug by using the -save-temps option.
Even though _Pragma is an extension to C++ and C89/90, it is a standard feature
in C99 and I can report that it ICEs in C99 mode also.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (8 preceding siblings ...)
  2006-05-24  3:45 ` pinskia at gcc dot gnu dot org
@ 2006-05-25 12:29 ` jakub at gcc dot gnu dot org
  2006-05-25 15:47 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-05-25 12:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jakub at gcc dot gnu dot org  2006-05-25 12:29 -------
 #define parallel _Pragma("omp parallel")
 int
 main()
 {
 #pragma omp parallel
 {}
 }

is ICE on invalid code, OpenMP 2.5 says in 2.1 Directive Format:
Preprocessing tokens following the #pragma omp are subject to macro
replacement.
And, #pragma omp _Pragma ("omp parallel")
is of course not valid.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (9 preceding siblings ...)
  2006-05-25 12:29 ` jakub at gcc dot gnu dot org
@ 2006-05-25 15:47 ` jakub at gcc dot gnu dot org
  2006-05-25 16:45 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-05-25 15:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jakub at gcc dot gnu dot org  2006-05-25 15:47 -------
So far fixed the valid cases of _Pragma with -fopenmp I came up, still need to
work some more on the invalid ones.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|2006-05-24 03:23:55         |2006-05-25 15:47:18
               date|                            |


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (10 preceding siblings ...)
  2006-05-25 15:47 ` jakub at gcc dot gnu dot org
@ 2006-05-25 16:45 ` pinskia at gcc dot gnu dot org
  2006-06-09 21:19 ` jakub at gcc dot gnu dot org
  2006-06-09 21:27 ` jakub at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-25 16:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pinskia at gcc dot gnu dot org  2006-05-25 16:44 -------
(In reply to comment #10)
>  #define parallel _Pragma("omp parallel")
>  int
>  main()
>  {
>  #pragma omp parallel
>  {}
>  }

This is not invalid according to:
http://gcc.gnu.org/onlinedocs/cpp/Implementation_002ddefined-behavior.html
Which says the following (unless that is not up to date also):

Treatment of a `#pragma' directive that after macro-expansion results in a
standard pragma.
No macro expansion occurs on any `#pragma' directive line, so the question does
not arise.

Note that GCC does not yet implement any of the standard pragmas.


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (11 preceding siblings ...)
  2006-05-25 16:45 ` pinskia at gcc dot gnu dot org
@ 2006-06-09 21:19 ` jakub at gcc dot gnu dot org
  2006-06-09 21:27 ` jakub at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-06-09 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from jakub at gcc dot gnu dot org  2006-06-09 21:13 -------
Subject: Bug 27746

Author: jakub
Date: Fri Jun  9 21:13:25 2006
New Revision: 114519

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114519
Log:
        PR preprocessor/27746
        * directives.c (do_pragma): Handle pragma with valid namespace
        and invalid name coming from macro expansion.
        * directives.c (destringize_and_run): Initialize next field in
        context.

        PR c/27747
        PR c++/27748
        * directives.c (destringize_and_run): Set NO_EXPAND on the
        tokens.

        * macro.c (_cpp_backup_tokens): Fix comment typo.
testsuite/
        PR c/27747
        * gcc.dg/cpp/_Pragma6.c: New test.

        PR c++/27748
        * g++.dg/cpp/_Pragma1.C: New test.

        PR preprocessor/27746
        * gcc.dg/gomp/macro-3.c: New test.
        * gcc.dg/gomp/macro-4.c: New test.
        * g++.dg/gomp/macro-3.C: New test.
        * g++.dg/gomp/macro-4.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp/_Pragma1.C
    trunk/gcc/testsuite/g++.dg/gomp/macro-3.C
    trunk/gcc/testsuite/g++.dg/gomp/macro-4.C
    trunk/gcc/testsuite/gcc.dg/cpp/_Pragma6.c
    trunk/gcc/testsuite/gcc.dg/gomp/macro-3.c
    trunk/gcc/testsuite/gcc.dg/gomp/macro-4.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/directives.c
    trunk/libcpp/macro.c


-- 


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


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

* [Bug preprocessor/27746] ICE on openmp code when using _Pragma from macro
  2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
                   ` (12 preceding siblings ...)
  2006-06-09 21:19 ` jakub at gcc dot gnu dot org
@ 2006-06-09 21:27 ` jakub at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-06-09 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from jakub at gcc dot gnu dot org  2006-06-09 21:26 -------
Should be fixed in SVN.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2006-06-09 21:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-24  1:46 [Bug c++/27746] New: ICE on openmp code when using _Pragma from macro bowie dot owens at csiro dot au
2006-05-24  1:47 ` [Bug c++/27746] " bowie dot owens at csiro dot au
2006-05-24  3:08 ` pinskia at gcc dot gnu dot org
2006-05-24  3:10 ` [Bug c/27746] " pinskia at gcc dot gnu dot org
2006-05-24  3:24 ` [Bug preprocessor/27746] " pinskia at gcc dot gnu dot org
2006-05-24  3:24 ` pinskia at gcc dot gnu dot org
2006-05-24  3:29 ` pinskia at gcc dot gnu dot org
2006-05-24  3:34 ` pinskia at gcc dot gnu dot org
2006-05-24  3:42 ` bowie dot owens at csiro dot au
2006-05-24  3:45 ` pinskia at gcc dot gnu dot org
2006-05-25 12:29 ` jakub at gcc dot gnu dot org
2006-05-25 15:47 ` jakub at gcc dot gnu dot org
2006-05-25 16:45 ` pinskia at gcc dot gnu dot org
2006-06-09 21:19 ` jakub at gcc dot gnu dot org
2006-06-09 21:27 ` jakub 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).