public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35198] New: missed evaluation of VM array type
@ 2008-02-14 18:58 mrs at apple dot com
2008-02-14 21:43 ` [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast rguenth at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: mrs at apple dot com @ 2008-02-14 18:58 UTC (permalink / raw)
To: gcc-bugs
void* a(void* x) {return (int (*)[10][printf("hi\n")])x;}
int main() { int i; a(&i); }
should print hi. This was still broken in 4.3 in July, 2007.
--
Summary: missed evaluation of VM array type
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mrs at apple dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
@ 2008-02-14 21:43 ` rguenth at gcc dot gnu dot org
2008-02-17 16:20 ` rguenth at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-14 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-02-14 21:42 -------
Confirmed.
This used to work with gcc 2.95 at least.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |3.3.6 4.1.3 4.3.0
Known to work| |2.95.4
Last reconfirmed|0000-00-00 00:00:00 |2008-02-14 21:42:39
date| |
Summary|missed evaluation of VM |[4.1/4.2/4.3 Regression]
|array type when used as a |missed evaluation of VM
|cast |array type when used as a
| |cast
Target Milestone|--- |4.2.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
2008-02-14 21:43 ` [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast rguenth at gcc dot gnu dot org
@ 2008-02-17 16:20 ` rguenth at gcc dot gnu dot org
2008-02-17 16:34 ` ebotcazou at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-17 16:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2008-02-17 16:19 -------
There are a few different cases. For
int foo(void);
void *a(void *p)
{
return (int (*)[foo()])p;
}
the frontend already got rid of the intermediate casts (and side-effects). For
int foo(void);
void a(void *p)
{
(int (*)[foo()])p;
}
the frontend retains the cast and the side-effects, but the gimplifier removes
them.
One error is certainly:
Breakpoint 3, fold_unary (code=NOP_EXPR, type=0xb7cee2d8, op0=0xb7d46140)
at /home/richard/src/trunk/gcc/fold-const.c:7932
7932 enum tree_code_class kind = TREE_CODE_CLASS (code);
(int[0:(unsigned int) (SAVE_EXPR <foo ()> + -1)] *) p
(gdb) call debug_generic_expr (type)
void *
(gdb) print op0->base.side_effects_flag
$1 = 0
that is, the conversion is not marked as producing side-effects (possibly
because the side-effect is wrapped in a SAVE_EXPR).
It is also not clear to me whether we should do so (wrap the call inside
a SAVE_EXPR). What is supposed to happen for
int foo(void);
void a(void *p)
{
(int (*)[foo()])p;
(int (*)[foo()])p;
}
? Is foo supposed to be called twice?
I think the burden should be on the side of the frontend to instead emit
a COMPOUND_EXPR like
( SAVE_EXPR<foo()>, (int (*)[SAVE_EXPR<foo()>])p )
here. At least marking the whole conversion as having no side-effects
doesn't tell the truth really, likewise if SAVE_EXPRs have no side-effects,
as that wouldn't guarantee it is evaluated at least once.
But maybe I am missing parts of GCC history here.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
2008-02-14 21:43 ` [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast rguenth at gcc dot gnu dot org
2008-02-17 16:20 ` rguenth at gcc dot gnu dot org
@ 2008-02-17 16:34 ` ebotcazou at gcc dot gnu dot org
2008-02-17 23:12 ` joseph at codesourcery dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-02-17 16:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ebotcazou at gcc dot gnu dot org 2008-02-17 16:33 -------
> At least marking the whole conversion as having no side-effects doesn't tell
> the truth really, likewise if SAVE_EXPRs have no side-effects, as that
> wouldn't guarantee it is evaluated at least once.
SAVE_EXPRs can have side-effects like every other expression, and save_expr
automatically sets the flag.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (2 preceding siblings ...)
2008-02-17 16:34 ` ebotcazou at gcc dot gnu dot org
@ 2008-02-17 23:12 ` joseph at codesourcery dot com
2008-02-17 23:22 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: joseph at codesourcery dot com @ 2008-02-17 23:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from joseph at codesourcery dot com 2008-02-17 23:12 -------
Subject: Re: [4.1/4.2/4.3 Regression] missed evaluation of VM
array type when used as a cast
My view remains as I said in
<http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00039.html>: front ends
should make the internal variable for VLA sizes explicit. This is not
however suitable for implementing in development stage 3, let alone in
regression-only mode or on release branches. There may of course be a
simpler fix for this particular bug.
I don't think side effects in VLA size expressions (let alone in VLA size
expressions in casts) are that likely to be used in real code outside of
conformance testsuites, so I wouldn't consider this regression (worked
with 2.95.3, failed with 3.0.4) of great importance.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (3 preceding siblings ...)
2008-02-17 23:12 ` joseph at codesourcery dot com
@ 2008-02-17 23:22 ` rguenth at gcc dot gnu dot org
2008-05-19 20:33 ` [Bug c/35198] [4.1/4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-17 23:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2008-02-17 23:21 -------
The variables get made explicit by the gimplifier. The problem here seems to
be that we lose the cast before we can do so and that the gimplifier only makes
the variables explicit if they are used (which they are not for casts - apart
from side-effects).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.1/4.2/4.3/4.4 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (4 preceding siblings ...)
2008-02-17 23:22 ` rguenth at gcc dot gnu dot org
@ 2008-05-19 20:33 ` jsm28 at gcc dot gnu dot org
2008-07-04 23:00 ` [Bug c/35198] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-05-19 20:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jsm28 at gcc dot gnu dot org 2008-05-19 20:24 -------
4.2.4 is being released, changing milestones to 4.2.5.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.2.4 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (5 preceding siblings ...)
2008-05-19 20:33 ` [Bug c/35198] [4.1/4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2008-07-04 23:00 ` jsm28 at gcc dot gnu dot org
2008-10-24 0:10 ` jsm28 at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 23:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2008-07-04 22:59 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3/4.4 Regression]|[4.2/4.3/4.4 Regression]
|missed evaluation of VM |missed evaluation of VM
|array type when used as a |array type when used as a
|cast |cast
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (6 preceding siblings ...)
2008-07-04 23:00 ` [Bug c/35198] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2008-10-24 0:10 ` jsm28 at gcc dot gnu dot org
2008-10-24 19:38 ` jsm28 at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-10-24 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jsm28 at gcc dot gnu dot org 2008-10-24 00:09 -------
Testing a patch for 4.5.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jsm28 at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2008-02-14 21:42:39 |2008-10-24 00:09:23
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (7 preceding siblings ...)
2008-10-24 0:10 ` jsm28 at gcc dot gnu dot org
@ 2008-10-24 19:38 ` jsm28 at gcc dot gnu dot org
2008-11-12 23:16 ` jsm28 at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-10-24 19:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jsm28 at gcc dot gnu dot org 2008-10-24 19:36 -------
Subject: Bug 35198
Author: jsm28
Date: Fri Oct 24 19:34:52 2008
New Revision: 141349
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141349
Log:
PR c/456
PR c/5675
PR c/19976
PR c/29116
PR c/31871
PR c/35198
fixincludes:
* inclhack.def (glibc_tgmath): New fix.
* fixincl.x: Regenerate.
* tests/base/tgmath.h: New.
gcc:
* builtins.c (fold_call_expr): Return a NOP_EXPR from folding
rather than the contained expression.
* c-common.c (c_save_expr): New.
(c_common_truthvalue_conversion): Use c_save_expr. Do not fold
conditional expressions for C.
* c-common.def (C_MAYBE_CONST_EXPR): New.
* c-common.h (c_fully_fold, c_save_expr): New prototypes.
(C_MAYBE_CONST_EXPR_PRE, C_MAYBE_CONST_EXPR_EXPR,
C_MAYBE_CONST_EXPR_INT_OPERANDS, C_MAYBE_CONST_EXPR_NON_CONST,
EXPR_INT_CONST_OPERANDS): Define.
* c-convert.c (convert): Strip nops from expression.
* c-decl.c (groktypename): Take extra parameters expr and
expr_const_operands. Update call to grokdeclarator.
(start_decl): Update call to grokdeclarator. Add statement for
expressions used in type of decl.
(grokparm): Update call to grokdeclarator.
(push_parm_decl): Update call to grokdeclarator.
(build_compound_literal): Add parameter non_const and build a
C_MAYBE_COSNT_EXPR if applicable.
(grokdeclarator): Take extra parameters expr and
expr_const_operands. Track expressions used in declaration
specifiers and declarators. Fold array sizes and track whether
they are constant expressions and whether they are integer
constant expressions.
(parser_xref_tag): Set expr and expr_const_operands fields in
return value.
(grokfield): Update call to grokdeclarator.
(start_function): Update call to grokdeclarator.
(build_null_declspecs): Set expr and expr_const_operands fields in
return value.
(declspecs_add_type): Handle expressions in typeof specifiers.
* c-parser.c (c_parser_declspecs): Set expr and
expr_const_operands fields for declaration specifiers.
(c_parser_enum_specifier): Likewise.
(c_parser_struct_or_union_specifier): Likewise.
(c_parser_typeof_specifier): Likewise. Update call to
groktypename. Fold expression as needed. Return expressions with
type instead of adding statements.
(c_parser_attributes): Update calls to c_parser_expr_list.
(c_parser_statement_after_labels): Fold expression before passing
to objc_build_throw_stmt.
(c_parser_condition): Fold expression.
(c_parser_asm_operands): Fold expression.
(c_parser_conditional_expression): Use c_save_expr. Update call
to build_conditional_expr.
(c_parser_alignof_expression): Update call to groktypename.
(c_parser_postfix_expression): Preserve C_MAYBE_CONST_EXPR as
original_code. Fold expression argument of va_arg. Create
C_MAYBE_CONST_EXPR to preserve side effects of expressions in type
argument to va_arg. Update calls to groktypename. Fold array
index for offsetof. Verify that first argument to
__builtin_choose_expr has integer type.
(c_parser_postfix_expression_after_paren_type): Update calls to
groktypename and build_compound_literal. Handle expressions with
side effects in type name.
(c_parser_postfix_expression_after_primary): Update call to
c_parser_expr_list. Set original_code for calls to
__builtin_constant_p.
(c_parser_expr_list): Take extra parameter fold_p. Fold
expressions if requested.
(c_parser_objc_type_name): Update call to groktypename.
(c_parser_objc_synchronized_statement): Fold expression.
(c_parser_objc_receiver): Fold expression.
(c_parser_objc_keywordexpr): Update call to c_parser_expr_list.
(c_parser_omp_clause_num_threads, c_parser_omp_clause_schedule,
c_parser_omp_atomic, c_parser_omp_for_loop): Fold expressions.
* c-tree.h (CONSTRUCTOR_NON_CONST): Define.
(struct c_typespec): Add elements expr and expr_const_operands.
(struct c_declspecs): Add elements expr and expr_const_operands.
(groktypename, build_conditional_expr, build_compound_literal):
Update prototypes.
* c-typeck.c (c_fully_fold, c_fully_fold_internal,
note_integer_operands): New functions.
(decl_constant_value_for_broken_optimization): Rename to
decl_constant_value_for_optimization: Check whether optimizing
and that the expression is a VAR_DECL not of array type instead of
doing such checks in the caller. Do not check pedantic.
(default_function_array_conversion): Do not strip nops.
(default_conversion): Do not call
decl_constant_value_for_broken_optimization.
(build_array_ref): Do not fold result.
(c_expr_sizeof_expr): Fold operand. Use C_MAYBE_CONST_EXPR for
result when operand is a VLA.
(c_expr_sizeof_type): Update call to groktypename. Handle
expressions included in type name. Use C_MAYBE_CONST_EXPR for
result when operand names a VLA type.
(build_function_call): Update call to build_compound_literal.
Only fold result for calls to __builtin_* functions. Strip
NOP_EXPR from INTEGER_CST returned from such functions.
(convert_arguments): Fold arguments. Update call to
convert_for_assignment.
(build_unary_op): Handle increment and decrement of
C_MAYBE_CONST_EXPR. Move lvalue checks for increment and
decrement earlier. Fold operand of increment and decrement.
Handle address of C_MAYBE_CONST_EXPR. Only fold expression being
built for integer operand. Wrap returns that are INTEGER_CSTs
without being integer constant expressions or that have integer
constant operands without being INTEGER_CSTs.
(lvalue_p): Handle C_MAYBE_CONST_EXPR.
(build_conditional_expr): Add operand ifexp_bcp. Track whether
result is an integer constant expression or can be used in
unevaluated parts of one and avoid folding and wrap as
appropriate.
(build_compound_expr): Wrap result for C99 if operands can be used
in integer constant expressions.
(build_c_cast): Update call to digest_init. Do not ignore
overflow from casting floating-point constants to integers. Wrap
results that could be confused with integer constant expressions,
null pointer constants or floating-point constants.
(c_cast_expr): Update call to groktypename. Handle expressions
included in type name.
(build_modify_expr): Handle modifying a C_MAYBE_CONST_EXPR. Fold
lhs inside possible SAVE_EXPR. Fold RHS before assignment.
Update calls to convert_for_assignment.
(convert_for_assignment): Take new parameter
null_pointer_constant. Do not strip nops or call
decl_constant_value_for_broken_optimization.
(store_init_value): Update call to digest_init.
(digest_init): Take new parameter null_pointer_constant. Do not
call decl_constant_value_for_broken_optimization. pedwarn for
initializers not constant expressions. Update calls to
convert_for_assignment.
(constructor_nonconst): New.
(struct constructor_stack): Add nonconst element.
(really_start_incremental_init, push_init_level, pop_init_level):
Handle constructor_nonconst and nonconst element.
(set_init_index): Call constant_expression_warning for array
designators.
(output_init_element): Fold value. Set constructor_nonconst as
applicable. pedwarn for initializers not constant expressions.
Update call to digest_init. Call constant_expression_warning
where constant initializers are required.
(process_init_element): Use c_save_expr.
(c_finish_goto_ptr): Fold expression.
(c_finish_return): Fold return value. Update call to
convert_for_assignment.
(c_start_case): Fold switch expression.
(c_process_expr_stmt): Fold expression.
(c_finish_stmt_expr): Create C_MAYBE_CONST_EXPR as needed to
ensure statement expression is not evaluated in constant
expression.
(build_binary_op): Track whether results are integer constant
expressions or may occur in such, disable folding and wrap results
as applicable.
(c_objc_common_truthvalue_conversion): Handle results folded to
integer constants that are not integer constant expressions.
* doc/extend.texi: Document when typeof operands are evaluated,
that condition of __builtin_choose_expr is an integer constant
expression, and more about use of __builtin_constant_p in
initializers.
gcc/cp:
* typeck.c (c_fully_fold): New.
gcc/testsuite:
* gcc.dg/bconstp-2.c, gcc.dg/c90-const-expr-6.c,
gcc.dg/c90-const-expr-7.c, gcc.dg/c90-const-expr-8.c,
gcc.dg/c90-const-expr-9.c, gcc.dg/c90-const-expr-10.c,
gcc.dg/c90-const-expr-11.c, gcc.dg/c99-const-expr-6.c,
gcc.dg/c99-const-expr-7.c, gcc.dg/c99-const-expr-8.c,
gcc.dg/c99-const-expr-9.c, gcc.dg/c99-const-expr-10.c,
gcc.dg/c99-const-expr-11.c, gcc.dg/c99-const-expr-12.c,
gcc.dg/c99-const-expr-13.c, gcc.dg/gnu89-const-expr-1.c,
gcc.dg/gnu89-const-expr-2.c, gcc.dg/gnu99-const-expr-1.c,
gcc.dg/gnu99-const-expr-2.c, gcc.dg/gnu99-const-expr-3.c,
gcc.dg/vla-11.c, gcc.dg/vla-12.c, gcc.dg/vla-13.c,
gcc.dg/vla-14.c, gcc.dg/vla-15.c: New tests.
* gcc.dg/c90-const-expr-1.c, gcc.dg/c90-const-expr-2.c,
gcc.dg/c90-const-expr-3.c, gcc.dg/c99-const-expr-2.c,
gcc.dg/c99-const-expr-3.c, gcc.dg/c99-static-1.c: Remove XFAILs.
* gcc.dg/overflow-warn-1.c, gcc.dg/overflow-warn-2.c,
gcc.dg/overflow-warn-3.c, gcc.dg/overflow-warn-4.c: Remove
XFAILs. Update expected messages.
* gcc.dg/pr14649-1.c, gcc.dg/pr19984.c, gcc.dg/pr25682.c: Update
expected messages.
* gcc.dg/real-const-1.c: Replace with test from original PR.
Added:
branches/c-4_5-branch/fixincludes/ChangeLog.c45
branches/c-4_5-branch/fixincludes/tests/base/tgmath.h
branches/c-4_5-branch/gcc/ChangeLog.c45
branches/c-4_5-branch/gcc/cp/ChangeLog.c45
branches/c-4_5-branch/gcc/testsuite/ChangeLog.c45
branches/c-4_5-branch/gcc/testsuite/gcc.dg/bconstp-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-10.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-11.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-6.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-7.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-8.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-9.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-10.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-11.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-12.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-13.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-6.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-7.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-8.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-9.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/gnu89-const-expr-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/gnu99-const-expr-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/gnu99-const-expr-3.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/vla-11.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/vla-12.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/vla-13.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/vla-14.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/vla-15.c
Modified:
branches/c-4_5-branch/fixincludes/fixincl.x
branches/c-4_5-branch/fixincludes/inclhack.def
branches/c-4_5-branch/gcc/builtins.c
branches/c-4_5-branch/gcc/c-common.c
branches/c-4_5-branch/gcc/c-common.def
branches/c-4_5-branch/gcc/c-common.h
branches/c-4_5-branch/gcc/c-convert.c
branches/c-4_5-branch/gcc/c-decl.c
branches/c-4_5-branch/gcc/c-parser.c
branches/c-4_5-branch/gcc/c-tree.h
branches/c-4_5-branch/gcc/c-typeck.c
branches/c-4_5-branch/gcc/cp/typeck.c
branches/c-4_5-branch/gcc/doc/extend.texi
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c90-const-expr-3.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-const-expr-3.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-static-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/overflow-warn-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/overflow-warn-2.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/overflow-warn-3.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/overflow-warn-4.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/pr14649-1.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/pr19984.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/pr25682.c
branches/c-4_5-branch/gcc/testsuite/gcc.dg/real-const-1.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (8 preceding siblings ...)
2008-10-24 19:38 ` jsm28 at gcc dot gnu dot org
@ 2008-11-12 23:16 ` jsm28 at gcc dot gnu dot org
2009-03-29 18:14 ` [Bug c/35198] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-03-29 18:23 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-11-12 23:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jsm28 at gcc dot gnu dot org 2008-11-12 23:15 -------
Although technically wrong-code, side effects in VLA size expressions are a
very dubious practice I don't expect to be used like this outside of
testsuites.
The fix is clearly unsuitable for any development stage other than Stage 1;
downgrading to P4 to reflect this.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P2 |P4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4/4.5 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (9 preceding siblings ...)
2008-11-12 23:16 ` jsm28 at gcc dot gnu dot org
@ 2009-03-29 18:14 ` jsm28 at gcc dot gnu dot org
2009-03-29 18:23 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-29 18:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jsm28 at gcc dot gnu dot org 2009-03-29 18:14 -------
Subject: Bug 35198
Author: jsm28
Date: Sun Mar 29 18:13:43 2009
New Revision: 145254
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145254
Log:
PR c/456
PR c/5675
PR c/19976
PR c/29116
PR c/31871
PR c/35198
fixincludes:
* inclhack.def (glibc_tgmath): New fix.
* fixincl.x: Regenerate.
* tests/base/tgmath.h: New.
gcc:
* builtins.c (fold_builtin_sincos): Build COMPOUND_EXPR in
void_type_node.
(fold_call_expr): Return a NOP_EXPR from folding rather than the
contained expression.
* c-common.c (c_fully_fold, c_fully_fold_internal, c_save_expr):
New.
(c_common_truthvalue_conversion): Use c_save_expr. Do not fold
conditional expressions for C.
(decl_constant_value_for_optimization): Move from
decl_constant_value_for_broken_optimization in c-typeck.c. Check
whether optimizing and that the expression is a VAR_DECL not of
array type instead of doing such checks in the caller. Do not
check pedantic. Call gcc_unreachable for C++.
* c-common.def (C_MAYBE_CONST_EXPR): New.
* c-common.h (c_fully_fold, c_save_expr,
decl_constant_value_for_optimization): New prototypes.
(C_MAYBE_CONST_EXPR_PRE, C_MAYBE_CONST_EXPR_EXPR,
C_MAYBE_CONST_EXPR_INT_OPERANDS, C_MAYBE_CONST_EXPR_NON_CONST,
EXPR_INT_CONST_OPERANDS): Define.
* c-convert.c (convert): Strip nops from expression.
* c-decl.c (groktypename): Take extra parameters expr and
expr_const_operands. Update call to grokdeclarator.
(start_decl): Update call to grokdeclarator. Add statement for
expressions used in type of decl.
(grokparm): Update call to grokdeclarator.
(push_parm_decl): Update call to grokdeclarator.
(build_compound_literal): Add parameter non_const and build a
C_MAYBE_COSNT_EXPR if applicable.
(grokdeclarator): Take extra parameters expr and
expr_const_operands. Track expressions used in declaration
specifiers and declarators. Fold array sizes and track whether
they are constant expressions and whether they are integer
constant expressions.
(parser_xref_tag): Set expr and expr_const_operands fields in
return value.
(grokfield): Update call to grokdeclarator.
(start_function): Update call to grokdeclarator.
(build_null_declspecs): Set expr and expr_const_operands fields in
return value.
(declspecs_add_type): Handle expressions in typeof specifiers.
* c-parser.c (c_parser_declspecs): Set expr and
expr_const_operands fields for declaration specifiers.
(c_parser_enum_specifier): Likewise.
(c_parser_struct_or_union_specifier): Likewise.
(c_parser_typeof_specifier): Likewise. Update call to
groktypename. Fold expression as needed. Return expressions with
type instead of adding statements.
(c_parser_attributes): Update calls to c_parser_expr_list.
(c_parser_statement_after_labels): Fold expression before passing
to objc_build_throw_stmt.
(c_parser_condition): Fold expression.
(c_parser_asm_operands): Fold expression.
(c_parser_conditional_expression): Use c_save_expr. Update call
to build_conditional_expr.
(c_parser_alignof_expression): Update call to groktypename.
(c_parser_postfix_expression): Preserve C_MAYBE_CONST_EXPR as
original_code. Fold expression argument of va_arg. Create
C_MAYBE_CONST_EXPR to preserve side effects of expressions in type
argument to va_arg. Update calls to groktypename. Fold array
index for offsetof. Verify that first argument to
__builtin_choose_expr has integer type.
(c_parser_postfix_expression_after_paren_type): Update calls to
groktypename and build_compound_literal. Handle expressions with
side effects in type name.
(c_parser_postfix_expression_after_primary): Update call to
c_parser_expr_list. Set original_code for calls to
__builtin_constant_p.
(c_parser_expr_list): Take extra parameter fold_p. Fold
expressions if requested.
(c_parser_objc_type_name): Update call to groktypename.
(c_parser_objc_synchronized_statement): Fold expression.
(c_parser_objc_receiver): Fold expression.
(c_parser_objc_keywordexpr): Update call to c_parser_expr_list.
(c_parser_omp_clause_num_threads, c_parser_omp_clause_schedule,
c_parser_omp_atomic, c_parser_omp_for_loop): Fold expressions.
* c-tree.h (CONSTRUCTOR_NON_CONST): Define.
(struct c_typespec): Add elements expr and expr_const_operands.
(struct c_declspecs): Add elements expr and expr_const_operands.
(groktypename, build_conditional_expr, build_compound_literal):
Update prototypes.
(in_late_binary_op): Declare.
* c-typeck.c (note_integer_operands): New function.
(in_late_binary_op): New variable.
(decl_constant_value_for_broken_optimization): Move to c-common.c
and rename to decl_constant_value_for_optimization.
(default_function_array_conversion): Do not strip nops.
(default_conversion): Do not call
decl_constant_value_for_broken_optimization.
(build_array_ref): Do not fold result.
(c_expr_sizeof_expr): Fold operand. Use C_MAYBE_CONST_EXPR for
result when operand is a VLA.
(c_expr_sizeof_type): Update call to groktypename. Handle
expressions included in type name. Use C_MAYBE_CONST_EXPR for
result when operand names a VLA type.
(build_function_call): Update call to build_compound_literal.
Only fold result for calls to __builtin_* functions. Strip
NOP_EXPR from INTEGER_CST returned from such functions. Fold
the function designator.
(convert_arguments): Fold arguments. Update call to
convert_for_assignment.
(build_unary_op): Handle increment and decrement of
C_MAYBE_CONST_EXPR. Move lvalue checks for increment and
decrement earlier. Fold operand of increment and decrement.
Handle address of C_MAYBE_CONST_EXPR. Only fold expression being
built for integer operand. Wrap returns that are INTEGER_CSTs
without being integer constant expressions or that have integer
constant operands without being INTEGER_CSTs.
(lvalue_p): Handle C_MAYBE_CONST_EXPR.
(build_conditional_expr): Add operand ifexp_bcp. Track whether
result is an integer constant expression or can be used in
unevaluated parts of one and avoid folding and wrap as
appropriate. Fold operands before possibly doing -Wsign-compare
warnings.
(build_compound_expr): Wrap result for C99 if operands can be used
in integer constant expressions.
(build_c_cast): Update call to digest_init. Do not ignore
overflow from casting floating-point constants to integers. Wrap
results that could be confused with integer constant expressions,
null pointer constants or floating-point constants.
(c_cast_expr): Update call to groktypename. Handle expressions
included in type name.
(build_modify_expr): Handle modifying a C_MAYBE_CONST_EXPR. Fold
lhs inside possible SAVE_EXPR. Fold RHS before assignment.
Update calls to convert_for_assignment.
(convert_for_assignment): Take new parameter
null_pointer_constant. Do not strip nops or call
decl_constant_value_for_broken_optimization. Set
in_late_binary_op for conversions to boolean.
(store_init_value): Update call to digest_init.
(digest_init): Take new parameter null_pointer_constant. Do not
call decl_constant_value_for_broken_optimization. pedwarn for
initializers not constant expressions. Update calls to
convert_for_assignment.
(constructor_nonconst): New.
(struct constructor_stack): Add nonconst element.
(really_start_incremental_init, push_init_level, pop_init_level):
Handle constructor_nonconst and nonconst element.
(set_init_index): Call constant_expression_warning for array
designators.
(output_init_element): Fold value. Set constructor_nonconst as
applicable. pedwarn for initializers not constant expressions.
Update call to digest_init. Call constant_expression_warning
where constant initializers are required.
(process_init_element): Use c_save_expr.
(c_finish_goto_ptr): Fold expression.
(c_finish_return): Fold return value. Update call to
convert_for_assignment.
(c_start_case): Fold switch expression.
(c_process_expr_stmt): Fold expression.
(c_finish_stmt_expr): Create C_MAYBE_CONST_EXPR as needed to
ensure statement expression is not evaluated in constant
expression.
(build_binary_op): Track whether results are integer constant
expressions or may occur in such, disable folding and wrap results
as applicable. Fold operands for -Wsign-compare warnings unless
in_late_binary_op.
(c_objc_common_truthvalue_conversion): Handle results folded to
integer constants that are not integer constant expressions.
* doc/extend.texi: Document when typeof operands are evaluated,
that condition of __builtin_choose_expr is an integer constant
expression, and more about use of __builtin_constant_p in
initializers.
gcc/objc:
* objc-act.c (objc_finish_try_stmt): Set in_late_binary_op.
gcc/testsuite:
* gcc.c-torture/compile/20081108-1.c,
gcc.c-torture/compile/20081108-2.c,
gcc.c-torture/compile/20081108-3.c, gcc.dg/bconstp-2.c,
gcc.dg/bconstp-3.c, gcc.dg/bconstp-4.c, gcc.dg/c90-const-expr-6.c,
gcc.dg/c90-const-expr-7.c, gcc.dg/c90-const-expr-8.c,
gcc.dg/c90-const-expr-9.c, gcc.dg/c90-const-expr-10.c,
gcc.dg/c90-const-expr-11.c, gcc.dg/c99-const-expr-6.c,
gcc.dg/c99-const-expr-7.c, gcc.dg/c99-const-expr-8.c,
gcc.dg/c99-const-expr-9.c, gcc.dg/c99-const-expr-10.c,
gcc.dg/c99-const-expr-11.c, gcc.dg/c99-const-expr-12.c,
gcc.dg/c99-const-expr-13.c, gcc.dg/compare10.c,
gcc.dg/gnu89-const-expr-1.c, gcc.dg/gnu89-const-expr-2.c,
gcc.dg/gnu99-const-expr-1.c, gcc.dg/gnu99-const-expr-2.c,
gcc.dg/gnu99-const-expr-3.c, gcc.dg/vla-12.c, gcc.dg/vla-13.c,
gcc.dg/vla-14.c, gcc.dg/vla-15.c, gcc.dg/vla-16.c: New tests.
* gcc.dg/c90-const-expr-1.c, gcc.dg/c90-const-expr-2.c,
gcc.dg/c90-const-expr-3.c, gcc.dg/c99-const-expr-2.c,
gcc.dg/c99-const-expr-3.c, gcc.dg/c99-static-1.c: Remove XFAILs.
* gcc.dg/c90-const-expr-2.c: Use ZERO in place of 0 in another
case.
* gcc.dg/overflow-warn-1.c, gcc.dg/overflow-warn-2.c,
gcc.dg/overflow-warn-3.c, gcc.dg/overflow-warn-4.c: Remove
XFAILs. Update expected messages.
* gcc.dg/pr14649-1.c, gcc.dg/pr19984.c, gcc.dg/pr25682.c: Update
expected messages.
* gcc.dg/real-const-1.c: Replace with test from original PR.
* gcc.dg/vect/pr32230.c: Use intermediate cast to __PTRDIFF_TYPE__
when casting from non-constant integer to pointer.
Added:
trunk/fixincludes/tests/base/tgmath.h
trunk/gcc/testsuite/gcc.c-torture/compile/20081108-1.c
trunk/gcc/testsuite/gcc.c-torture/compile/20081108-2.c
trunk/gcc/testsuite/gcc.c-torture/compile/20081108-3.c
trunk/gcc/testsuite/gcc.dg/bconstp-2.c
trunk/gcc/testsuite/gcc.dg/bconstp-3.c
trunk/gcc/testsuite/gcc.dg/bconstp-4.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-10.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-11.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-6.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-7.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-8.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-9.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-10.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-11.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-12.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-13.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-6.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-7.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-8.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-9.c
trunk/gcc/testsuite/gcc.dg/compare10.c
trunk/gcc/testsuite/gcc.dg/gnu89-const-expr-1.c
trunk/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c
trunk/gcc/testsuite/gcc.dg/gnu99-const-expr-1.c
trunk/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c
trunk/gcc/testsuite/gcc.dg/gnu99-const-expr-3.c
trunk/gcc/testsuite/gcc.dg/vla-12.c
trunk/gcc/testsuite/gcc.dg/vla-13.c
trunk/gcc/testsuite/gcc.dg/vla-14.c
trunk/gcc/testsuite/gcc.dg/vla-15.c
trunk/gcc/testsuite/gcc.dg/vla-16.c
Modified:
trunk/fixincludes/ChangeLog
trunk/fixincludes/fixincl.x
trunk/fixincludes/inclhack.def
trunk/gcc/ChangeLog
trunk/gcc/builtins.c
trunk/gcc/c-common.c
trunk/gcc/c-common.def
trunk/gcc/c-common.h
trunk/gcc/c-convert.c
trunk/gcc/c-decl.c
trunk/gcc/c-parser.c
trunk/gcc/c-tree.h
trunk/gcc/c-typeck.c
trunk/gcc/doc/extend.texi
trunk/gcc/objc/ChangeLog
trunk/gcc/objc/objc-act.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/c90-const-expr-1.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-2.c
trunk/gcc/testsuite/gcc.dg/c90-const-expr-3.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-2.c
trunk/gcc/testsuite/gcc.dg/c99-const-expr-3.c
trunk/gcc/testsuite/gcc.dg/c99-static-1.c
trunk/gcc/testsuite/gcc.dg/overflow-warn-1.c
trunk/gcc/testsuite/gcc.dg/overflow-warn-2.c
trunk/gcc/testsuite/gcc.dg/overflow-warn-3.c
trunk/gcc/testsuite/gcc.dg/overflow-warn-4.c
trunk/gcc/testsuite/gcc.dg/pr14649-1.c
trunk/gcc/testsuite/gcc.dg/pr19984.c
trunk/gcc/testsuite/gcc.dg/pr25682.c
trunk/gcc/testsuite/gcc.dg/real-const-1.c
trunk/gcc/testsuite/gcc.dg/vect/pr32230.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/35198] [4.2/4.3/4.4/4.5 Regression] missed evaluation of VM array type when used as a cast
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
` (10 preceding siblings ...)
2009-03-29 18:14 ` [Bug c/35198] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-03-29 18:23 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-29 18:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jsm28 at gcc dot gnu dot org 2009-03-29 18:23 -------
Fixed for 4.5. Fix not suitable for backporting.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work|2.95.4 |2.95.4 4.5.0
Resolution| |FIXED
Target Milestone|4.2.5 |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35198
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-03-29 18:23 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-14 18:58 [Bug c/35198] New: missed evaluation of VM array type mrs at apple dot com
2008-02-14 21:43 ` [Bug c/35198] [4.1/4.2/4.3 Regression] missed evaluation of VM array type when used as a cast rguenth at gcc dot gnu dot org
2008-02-17 16:20 ` rguenth at gcc dot gnu dot org
2008-02-17 16:34 ` ebotcazou at gcc dot gnu dot org
2008-02-17 23:12 ` joseph at codesourcery dot com
2008-02-17 23:22 ` rguenth at gcc dot gnu dot org
2008-05-19 20:33 ` [Bug c/35198] [4.1/4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2008-07-04 23:00 ` [Bug c/35198] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2008-10-24 0:10 ` jsm28 at gcc dot gnu dot org
2008-10-24 19:38 ` jsm28 at gcc dot gnu dot org
2008-11-12 23:16 ` jsm28 at gcc dot gnu dot org
2009-03-29 18:14 ` [Bug c/35198] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-03-29 18:23 ` jsm28 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).