Bug 33314 - [glsl] ir_constant_expression.cpp:122: virtual ir_constant* ir_expression::constant_expression_value(): Assertion `op[0]->type->base_type == GLSL_TYPE_BOOL' failed.
Summary: [glsl] ir_constant_expression.cpp:122: virtual ir_constant* ir_expression::co...
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: All All
: medium critical
Assignee: Kenneth Graunke
QA Contact:
Depends on:
Reported: 2011-01-20 17:14 UTC by Vinson Lee
Modified: 2011-04-13 20:06 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Note You need to log in before you can comment on or make changes to this bug.
Description Vinson Lee 2011-01-20 17:14:32 UTC
mesa: 2fb0aebd4a248d2a0725099cd5646253c30c1dc3 (master)

This fragment shader triggers an assertion in the Mesa GLSL compiler.

void A(int a) {

void main()

   gl_FragColor = vec4(0.0);

ir_constant_expression.cpp:122: virtual ir_constant* ir_expression::constant_expression_value(): Assertion `op[0]->type->base_type == GLSL_TYPE_BOOL' failed.

(gdb) bt
#0  0x007d0416 in __kernel_vsyscall ()
#1  0x00918941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x0091be42 in abort () at abort.c:92
#3  0x009118e8 in __assert_fail (assertion=0x4656b0 "op[0]->type->base_type == GLSL_TYPE_BOOL", file=0x465600 "ir_constant_expression.cpp", line=122, 
    function=0x465d80 "virtual ir_constant* ir_expression::constant_expression_value()") at assert.c:81
#4  0x002a6b0a in ir_expression::constant_expression_value (this=0x904aff0) at ir_constant_expression.cpp:122
#5  0x003792d1 in process_parameters (instructions=0x9257b08, actual_parameters=0xbf9b9564, parameters=0x8f8038c, state=0x8f76108) at ast_function.cpp:48
#6  0x0037cab5 in ast_function_expression::hir (this=0x8f80360, instructions=0x9257b08, state=0x8f76108) at ast_function.cpp:1198
#7  0x00285be2 in ast_expression_statement::hir (this=0x8f804b0, instructions=0x9257b08, state=0x8f76108) at ast_to_hir.cpp:1701
#8  0x00285c42 in ast_compound_statement::hir (this=0x8f807c0, instructions=0x9257b08, state=0x8f76108) at ast_to_hir.cpp:1717
#9  0x002884b5 in ast_function_definition::hir (this=0x8f80288, instructions=0x8f7f198, state=0x8f76108) at ast_to_hir.cpp:2971
#10 0x00281287 in _mesa_ast_to_hir (instructions=0x8f7f198, state=0x8f76108) at ast_to_hir.cpp:85
#11 0x0027faae in _mesa_glsl_compile_shader (ctx=0x8f0a628, shader=0x8f75ff8) at program/ir_to_mesa.cpp:3109
#12 0x0022193c in compile_shader (ctx=0x8f0a628, shaderObj=1) at main/shaderapi.c:856
#13 0x0022228f in _mesa_CompileShaderARB (shaderObj=1) at main/shaderapi.c:1187

(gdb) frame 4
#4  0x002a6b0a in ir_expression::constant_expression_value (this=0x904aff0) at ir_constant_expression.cpp:122
122	      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
(gdb) print op[0]->type->base_type
(gdb) l
117	           assert(0);
118	       }
119	       break;
121	   case ir_unop_logic_not:
122	      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
123	      for (unsigned c = 0; c < op[0]->type->components(); c++)
124		 data.b[c] = !op[0]->value.b[c];
125	      break;
Comment 1 Eric Anholt 2011-04-13 18:09:27 UTC
commit 01822706ec2c2501a2cd2431a90c56b334b79a5c
Author: Eric Anholt <eric@anholt.net>
Date:   Sat Apr 9 15:59:20 2011 -1000

    glsl: Avoid cascading errors when looking for a scalar boolean and failing.
    By always using a boolean, we should generally avoid further
    complaints.  The failure case I see is logic_not, where the user might
    understandably make the mistake of using `!' on a boolean vector (like
    a piglit case did recently!), and then get a further complaint that
    the new boolean type doesn't match the bvec it gets assigned to.
    Fixes invalid-logic-not-06.vert (assertion failure when the bad type
    ends up in an expression and ir_constant_expression gets angry).
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33314
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Comment 2 Vinson Lee 2011-04-13 20:06:56 UTC
mesa: a9a02c8a39620515ec9fd0d774ce329cf67ecb4e (master)

Verified fixed.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct.