<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - -fsanitize=undefined reports errors on incorrect line"
   href="https://llvm.org/bugs/show_bug.cgi?id=22876">22876</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-fsanitize=undefined reports errors on incorrect line
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>oliverst@online.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code raises an error with -fsanitize=undefined:

t->nontextured_fpal_a = (UINT8)(nontextured_fpal_a * 255.0);

According to the backtrace I would expect it to actually report 

/home/notroot/trunk/src/mame/video/powervr2.c:678:36

as the source of the error.

/home/development/llvm/3.6.0/final/llvm.src/projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:302:3:
runtime error: value 267.75 is outside the range of representable values of
type 'unsigned char'
    #0 0x19b5055 in powervr2_device::tex_get_info(powervr2_device::texinfo*)
/home/notroot/trunk/src/mame/video/powervr2.c:678:36
    #1 0x19b7711 in powervr2_device::process_ta_fifo()
/home/notroot/trunk/src/mame/video/powervr2.c:1992:7
    #2 0x19b7865 in powervr2_device::ta_fifo_poly_w(address_space&, unsigned
int, unsigned long long, unsigned long long)
/home/notroot/trunk/src/mame/video/powervr2.c:2025:3
    #3 0x280e113 in delegate_base<void, address_space&, unsigned int, unsigned
long long, unsigned long long, _noparam, _noparam, _noparam, _noparam,
_noparam, _noparam, _noparam, _noparam>::operator()(address_space&, unsigned
int, unsigned long long, unsigned long long) const
/home/notroot/trunk/src/lib/util/delegate.h:655:90
    #4 0x280e113 in handler_entry_write::write64(address_space&, unsigned int,
unsigned long long, unsigned long long) const
/home/notroot/trunk/src/emu/memory.c:423
    #5 0x280e113 in address_space_specific<unsigned long long, (endianness_t)0,
true>::write_native(unsigned int, unsigned long long)
/home/notroot/trunk/src/emu/memory.c:1144
    #6 0x280dccb in address_space_specific<unsigned long long, (endianness_t)0,
true>::write_qword(unsigned int, unsigned long long)
/home/notroot/trunk/src/emu/memory.c:1435:73
    #7 0x1f59e2b in sh34_base_device::sh4_dma_transfer(int, int, unsigned int,
unsigned int*, unsigned int*, unsigned int*)
/home/notroot/trunk/src/emu/cpu/sh4/sh4dmac.c:171:4
    #8 0x1f5c01b in sh34_base_device::sh4_dma_ddt(sh4_ddt_dma*)
/home/notroot/trunk/src/emu/cpu/sh4/sh4dmac.c:523:3
    #9 0x19a4a42 in dc_state::dc_sysctrl_w(address_space&, unsigned int,
unsigned long long, unsigned long long)
/home/notroot/trunk/src/mame/machine/dc.c:410:5
    #10 0x280dfb5 in delegate_base<void, address_space&, unsigned int, unsigned
long long, unsigned long long, _noparam, _noparam, _noparam, _noparam,
_noparam, _noparam, _noparam, _noparam>::operator()(address_space&, unsigned
int, unsigned long long, unsigned long long) const
/home/notroot/trunk/src/lib/util/delegate.h:655:90
    #11 0x280dfb5 in handler_entry_write::write64(address_space&, unsigned int,
unsigned long long, unsigned long long) const
/home/notroot/trunk/src/emu/memory.c:423
    #12 0x280dfb5 in address_space_specific<unsigned long long,
(endianness_t)0, true>::write_native(unsigned int, unsigned long long, unsigned
long long) /home/notroot/trunk/src/emu/memory.c:1123
    #13 0x280db45 in void address_space_specific<unsigned long long,
(endianness_t)0, true>::write_direct<unsigned int, true>(unsigned int, unsigned
int, unsigned int) /home/notroot/trunk/src/emu/memory.c:1295:12
    #14 0x280db45 in address_space_specific<unsigned long long,
(endianness_t)0, true>::write_dword(unsigned int, unsigned int)
/home/notroot/trunk/src/emu/memory.c:1431
    #15 0x1f4d160 in sh34_base_device::WL(unsigned int, unsigned int)
/home/notroot/trunk/src/emu/cpu/sh4/sh4.c:285:2
    #16 0x1f4d160 in sh34_base_device::MOVLS4(unsigned short)
/home/notroot/trunk/src/emu/cpu/sh4/sh4.c:1403
    #17 0x1f4d160 in sh34_base_device::execute_one(unsigned short)
/home/notroot/trunk/src/emu/cpu/sh4/sh4.c:3649
    #18 0x1f48540 in sh34_base_device::execute_run()
/home/notroot/trunk/src/emu/cpu/sh4/sh4.c:3855:4
    #19 0x1f485ff in non-virtual thunk to sh34_base_device::execute_run()
/home/notroot/trunk/src/emu/cpu/sh4/sh4.c:3820:24
    #20 0x28500f5 in device_execute_interface::run()
/home/notroot/trunk/src/emu/diexec.h:191:15
    #21 0x28500f5 in device_scheduler::timeslice()
/home/notroot/trunk/src/emu/schedule.c:476
    #22 0x27eba97 in running_machine::run(bool)
/home/notroot/trunk/src/emu/machine.c:397:5
    #23 0x27e83c8 in machine_manager::execute()
/home/notroot/trunk/src/emu/mame.c:222:11
    #24 0x274449d in cli_frontend::execute(int, char**)
/home/notroot/trunk/src/emu/clifront.c:220:15
    #25 0x1a01dfc in main /home/notroot/trunk/src/osd/sdl/sdlmain.c:290:9
    #26 0x7f41acc11ec4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
    #27 0xdb2b65 in _start (/home/notroot/trunk/mess64d+0xdb2b65)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>