Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1682941 - -O2 level (apparently) elided foo = std::max(foo,1) before foo = std::min(foo, CONST)
Summary: -O2 level (apparently) elided foo = std::max(foo,1) before foo = std::min(foo...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 30
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1678319
TreeView+ depends on / blocked
 
Reported: 2019-02-25 21:37 UTC by Caolan McNamara
Modified: 2019-03-02 13:33 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-02 13:33:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
preprocessed code (5.66 MB, text/plain)
2019-02-25 21:37 UTC, Caolan McNamara
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 89505 0 None None None 2019-03-04 10:10:40 UTC

Description Caolan McNamara 2019-02-25 21:37:51 UTC
Created attachment 1538599 [details]
preprocessed code

Description of problem:

code of...

nColCount = 1;
...
nColCount = std::max<sal_Int32>(aIter.toInt32(), 1);
nColCount = std::min<sal_Int32>(nColCount, MAXCOLCOUNT);

results as if std::max line was elided, nColCount ends as 1 regardless of result of aIter.toInt32()

Version-Release number of selected component (if applicable):
gcc-9.0.1-0.4.fc30

How reproducible:
100%

Steps to Reproduce:
1. g++ -std=gnu++2a -fPIC -c -O2 ~/xmlcoli.ii

Actual results:
linking that into LibreOffice gives failure as described in bug #1678319

Additional info:
2. g++ -std=gnu++2a -fPIC -c -O1 ~/xmlcoli.ii

is ok, and rewriting as 

nColCount = aIter.toInt32();
if (nColCount < 1)
    nColCount = 1;
else if (nColCount > MAXCOLCOUNT)
    nColCount = MAXCOLCOUNT;

works fine

Comment 1 Jakub Jelinek 2019-02-28 13:19:12 UTC
Please try gcc-9.0.1-0.8.fc30.

Comment 2 Caolan McNamara 2019-03-02 13:33:45 UTC
works great, thanks


Note You need to log in before you can comment on or make changes to this bug.