From patchwork Wed Sep 10 10:12:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 387669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E652E14011D for ; Wed, 10 Sep 2014 20:12:39 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=Zq1tHD8D5mzeANwSkTy+jyn3vGFr+Y3Z9dLfmdpLwsiSfyQJEP PrGGQjTvfVPi0cDPtb+/B5mh19n8TLt88dwgN7EUB39G5gBwJMB39H099Ty6PGPz B9wdXiP7hFmilvsBukrn7l8YIUGchStZSsAMjuWk2NA96JFXvWCYTYnKw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=z2uyMwzPNZt0U05gdusRuhl55+Y=; b=F6uymffhkYEWqDLLNl27 2sEw+Y8uUhQ+0k2AzM28NYekbL/s4CQMNYvYLavN6NA42EMz7uhptDJ+QR0Ehur2 5f+ogE9b1xaYQ6FWy9AI3w1fJhJ2FKyylNiVjXoSydf6W7uJgwZaVQB9F3DQH1zj x0QOYkTZgPaLZPe3JbSnLJk= Received: (qmail 2996 invoked by alias); 10 Sep 2014 10:12:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2985 invoked by uid 89); 10 Sep 2014 10:12:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, T_FROM_12LTRDOM autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Sep 2014 10:12:29 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XResz-0001cf-Kp from Thomas_Schwinge@mentor.com ; Wed, 10 Sep 2014 03:12:26 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 10 Sep 2014 11:12:24 +0100 From: Thomas Schwinge To: Jakub Jelinek CC: Subject: [C++, OpenMP] Crash when OpenMP target's array section handling is used with templates User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Wed, 10 Sep 2014 12:12:03 +0200 Message-ID: <87zje7rdho.fsf@schwinge.name> MIME-Version: 1.0 Hi! Are the following issues known? template void f(T A, T B) { extern int *v; T a = 2; T b = 4; #pragma omp target map(to: v[a:b]) v[a] = 0; #pragma omp target map(to: v[A:B]) v[a] = 0; } void g() { f(1, 5); } ../../openacc/T.C: In function 'void f(T, T)': ../../openacc/T.C:8:35: internal compiler error: Segmentation fault 0xc1833f crash_signal ../../source/gcc/toplev.c:339 0x697f0d tree_class_check ../../source/gcc/tree.h:2851 0x697f0d cp_omp_mappable_type(tree_node*) ../../source/gcc/cp/decl2.c:1393 0x764777 finish_omp_clauses(tree_node*) ../../source/gcc/cp/semantics.c:5671 0x6d3d39 cp_parser_omp_all_clauses ../../source/gcc/cp/parser.c:28680 0x6c6265 cp_parser_omp_target ../../source/gcc/cp/parser.c:30649 [...] The following patch avoids the crash but doesn't resolve the issue itself: ../../openacc/T.C: In function 'void f(T, T)': ../../openacc/T.C:8:28: error: array section does not have mappable type in 'map' clause #pragma omp target map(to: v[a:b]) ^ ../../openacc/T.C:11:28: error: array section does not have mappable type in 'map' clause #pragma omp target map(to: v[A:B]) ^ For additional fun, replace »v[a] = 0;« with just »;«, and see: ../../openacc/T.C: In function 'void f(T, T)': ../../openacc/T.C:8:28: error: array section does not have mappable type in 'map' clause #pragma omp target map(to: v[a:b]) ^ ../../openacc/T.C:11:28: error: array section does not have mappable type in 'map' clause #pragma omp target map(to: v[A:B]) ^ ../../openacc/T.C: In instantiation of 'void f(T, T) [with T = int]': ../../openacc/T.C:17:9: required from here ../../openacc/T.C:4:15: warning: unused variable 'v' [-Wunused-variable] extern int *v; ^ ../../openacc/T.C: In function 'void f(T, T) [with T = int]': ../../openacc/T.C:8:9: internal compiler error: Segmentation fault #pragma omp target map(to: v[a:b]) ^ 0xc1833f crash_signal ../../source/gcc/toplev.c:339 0xa51624 gimplify_omp_workshare ../../source/gcc/gimplify.c:7137 0xa3facb gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../source/gcc/gimplify.c:8144 0xa432c6 gimplify_stmt(tree_node**, gimple_statement_base**) ../../source/gcc/gimplify.c:5416 0xa3ec93 gimplify_statement_list ../../source/gcc/gimplify.c:1450 0xa3ec93 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../source/gcc/gimplify.c:8090 0xa432c6 gimplify_stmt(tree_node**, gimple_statement_base**) ../../source/gcc/gimplify.c:5416 0xa44147 gimplify_bind_expr ../../source/gcc/gimplify.c:1099 [...] Program received signal SIGSEGV, Segmentation fault. gimplify_omp_workshare (expr_p=expr_p@entry=0x7ffff6845988, pre_p=pre_p@entry=0x7fffffffca68) at ../../source/gcc/gimplify.c:7137 7137 if (gimple_code (g) == GIMPLE_BIND) (gdb) print g $1 = (gimple) 0x0 (gdb) list 7132 gimplify_scan_omp_clauses (&OMP_CLAUSES (expr), pre_p, ort); 7133 if (ort == ORT_TARGET || ort == ORT_TARGET_DATA) 7134 { 7135 push_gimplify_context (); 7136 gimple g = gimplify_and_return_first (OMP_BODY (expr), &body); 7137 if (gimple_code (g) == GIMPLE_BIND) 7138 pop_gimplify_context (g); 7139 else 7140 pop_gimplify_context (NULL); 7141 if (ort == ORT_TARGET_DATA) (gdb) print expr $2 = (tree) 0x7ffff6835988 (gdb) call debug_tree(expr) > side-effects tree_1 arg 0 head (nil) tail (nil) stmts > ../../openacc/T.C:8:9> Grüße, Thomas diff --git gcc/cp/decl2.c gcc/cp/decl2.c index 4be4847..b418156 100644 --- gcc/cp/decl2.c +++ gcc/cp/decl2.c @@ -1390,7 +1390,7 @@ bool cp_omp_mappable_type (tree type) { /* Mappable type has to be complete. */ - if (type == error_mark_node || !COMPLETE_TYPE_P (type)) + if (type == error_mark_node || !type || !COMPLETE_TYPE_P (type)) return false; /* Arrays have mappable type if the elements have mappable type. */ while (TREE_CODE (type) == ARRAY_TYPE)